private void QueueProcessingThreadCallback(object state) { IChoQueuedMsgServiceObject <T> msgQObject = null; while (true) { try { msgQObject = _queue.Dequeue() as IChoQueuedMsgServiceObject <T>; if (msgQObject == null) { continue; } if (msgQObject.IsQuitServiceMsg) { break; } QueueMessageHandler(msgQObject); } catch (ChoFatalApplicationException fex) { ChoEnvironment.Exit(-1, fex); } catch (Exception ex) { ChoApplication.WriteToEventLog(ex.ToString(), EventLogEntryType.Error); if (msgQObject != null) { ChoApplication.WriteToEventLog(ChoObject.ToString(msgQObject)); } //ChoProfile.DefaultContext.Append(ex); //if (!EventLog.SourceExists(ChoAssembly.GetEntryAssembly().GetName().Name)) // EventLog.CreateEventSource(ChoAssembly.GetEntryAssembly().GetName().Name, "Application"); //EventLog.WriteEntry(ChoAssembly.GetEntryAssembly().GetName().Name, ChoApplicationException.ToString(ex)); //throw; } } }
private void QueueMessageHandler(IChoQueuedMsgServiceObject <ChoExecutionServiceData> msgObject) { if (msgObject == null || !ChoGuard.IsArgumentNotNullOrEmpty(msgObject.State) ) { return; } ChoAsyncResult asyncResult = msgObject.State.Result as ChoAsyncResult; try { object retValue = msgObject.State.Func.Run(msgObject.State.Parameters, msgObject.State.Timeout, msgObject.State.MaxNoOfRetry, msgObject.State.SleepBetweenRetry); asyncResult.SetAsSuccess(retValue, true); } catch (ThreadAbortException) { Thread.ResetAbort(); ChoTrace.Error("Thread aborted." + msgObject.State.ToString()); asyncResult.SetAsAborted(true); } catch (ChoFatalApplicationException fex) { ChoTrace.Error(fex); ChoTrace.Error(msgObject.State.ToString()); asyncResult.SetAsFailed(fex, true); ChoEnvironment.Exit(-1, fex); } catch (Exception ex) { ChoTrace.Error(ex); ChoTrace.Error(msgObject.State.ToString()); asyncResult.SetAsFailed(ex, true); } }