Guest User

Untitled

a guest
Jun 18th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. System.Timers.Timer statustimer =
  2. new System.Timers.Timer(
  3. double.Parse(ConfigurationManager.AppSettings["NotificationSendPeriod"]));
  4. statustimer.Elapsed += ((sender, eventArgs) =>
  5. {
  6. try
  7. {
  8. ProcessData();
  9. }
  10. catch (Exception e)
  11. {
  12. Console.WriteLine(e);
  13.  
  14. }
  15. });
  16. statustimer.Enabled = true; Console.ReadLine();
  17.  
  18. public static async Task<bool> ProcessData()
  19. {
  20. try
  21. {
  22. new Thread(() =>
  23. {
  24. // Do work here
  25.  
  26. }).Start();
  27.  
  28.  
  29.  
  30. return true;
  31. }
  32. catch (Exception exception)
  33. {
  34. Console.WriteLine(exception);
  35. _logInstance?.Error(exception, $"{exception.Message}n{exception.StackTrace}");
  36. return false;
  37. }
  38. }
Add Comment
Please, Sign In to add comment