public void Execute() { try { lock (_lock) { if (_shuttingDown) { return; } if (IsBusyImporting) { return; } IsBusyImporting = true; SmsProcessingHelper smsHelper = new SmsProcessingHelper(GlobalHost.ConnectionManager.GetHubContext <ServerSentEventsHub>()); smsHelper.Import(); IsBusyImporting = false; Debug.WriteLine($"[{DateTime.Now}] Importing finished"); } } finally { // Always unregister the job when done. HostingEnvironment.UnregisterObject(this); } }
public void Execute() { try { lock (_lock) { if (_shuttingDown) { return; } if (IsBusyImporting) { return; } SmsProcessingHelper smsHelper = new SmsProcessingHelper(GlobalHost.ConnectionManager.GetHubContext <ServerSentEventsHub>()); smsHelper.Enqueue(BATCHSIZE); } } finally { // Always unregister the job when done. HostingEnvironment.UnregisterObject(this); } }