Guest User

Untitled

a guest
Aug 14th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. Best way to mark Client Offline using Web-Service
  2. [WebMethod]
  3. public string Connect(Size desktopsize)
  4. {
  5. Client clienti = new Client();
  6. clienti.ID = "Client_" + Counter.ToString();
  7. clienti.Desktopsize = desktopsize;
  8. clienti.Lastupdate = DateTime.Now;
  9. Counter++;
  10. clients.Add(clienti);
  11. return clienti.ID;
  12. }
  13.  
  14. public bool SingleClick
  15. {
  16. get
  17. {
  18. bool tmpBolean = singleclick;
  19. singleclick = false;
  20. return tmpBolean;
  21. }
  22. set
  23. {
  24. this.lastupdate = DateTime.Now;
  25. singleclick = value;
  26. }
  27. }
  28.  
  29. private void CheckOnlinestate()
  30. {
  31. while (isRunning)
  32. {
  33. TimeSpan ts = DateTime.Now - lastupdate;
  34. if (ts.TotalMinutes >= 1)
  35. {
  36. isRunning = false;
  37. this.Dispose();
  38. }
  39. }
  40. }
  41.  
  42. public void CheckClients()
  43. {
  44. while (true)
  45. {
  46. foreach (Client c in clients)
  47. {
  48. if (c.ShouldDispose)
  49. {
  50. clients.Remove(c);
  51. }
  52. }
  53. Thread.Sleep(200);
  54. }
  55. }
Add Comment
Please, Sign In to add comment