示例#1
0
 public DataService()
 {
     this.userBugs              = new MultiThreadingObservableCollection <Bug>();
     this.teamBugs              = new MultiThreadingObservableCollection <Bug>();
     this.refreshTime           = DateTime.Now;
     this.userBugsQueryState    = QueryStatus.QureyPause;
     this.userBugsProgressValue = 0;
     this.teamBugsQueryState    = QueryStatus.QureyPause;
     this.teamBugsProgressValue = 0;
     this.initializeStatus      = InitializeStatus.Initializing;
 }
示例#2
0
 public DataService()
 {
     this.userBugs = new MultiThreadingObservableCollection<Bug>();
     this.teamBugs = new MultiThreadingObservableCollection<Bug>();
     this.refreshTime = DateTime.Now;
     this.userBugsQueryState = QueryStatus.QureyPause;
     this.userBugsProgressValue = 0;
     this.teamBugsQueryState = QueryStatus.QureyPause;
     this.teamBugsProgressValue = 0;
     this.initializeStatus = InitializeStatus.Initializing;
 }
示例#3
0
        /// <summary>
        /// Getting the messages from the queue and process them.
        /// </summary>
        private void ProcessMessagesAsync()
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "ProcessMessagesAsync");

            _startAsyncStatus = InitializeStatus.Completed;
            bool isShutdown = false;

            this.ExecutorService.AddExecutor(this);

            try
            {
                // before process the messages
                try
                {
                    this.OnPreProcessMessagesAsync();
                }
                catch { }

                // actual message processing
                while (!this.ExecutorService.WaitForShutdown(_queueTimeout))
                {
                    GetMessage(out isShutdown);
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
            finally
            {
                // after process the messages
                try
                {
                    this.OnPostProcessMessagesAsync();
                }
                catch { /* No Interest to log the message */ }

                this.Shutdown();
            }
        }
        private void DoWork()
        {
            ModuleProc PROC = new ModuleProc(DYN_MODULE_NAME, "DoWork");

            _doWorkInitialized = InitializeStatus.Completed;
            int threadId = Thread.CurrentThread.ManagedThreadId;

            _workerThreadId = threadId;

            try
            {
                while (!this.ExecutorService.WaitForShutdown())
                {
                    T item = default(T);

                    try
                    {
                        ThreadExecutorItem <T> executorItem = _queue.Dequeue();
                        if (this.ExecutorService.IsShutdown)
                        {
                            Log.Info(PROC, string.Format("Shutdown called. Thread : {0:D} is exiting now.", threadId));
                            break;
                        }
                        if (executorItem == null)
                        {
                            Log.Info(PROC, "Invalid executor item received.");
                            continue;
                        }

                        // actual item
                        Log.DescriptionV(PROC, "Thread : {0:D}, Queue Size : {1:D}", threadId, _queue.QueueCount);
                        item = executorItem.Item;

                        // if any preceeding item there, then wait for it to finish
                        if (executorItem.WaitHandle != null)
                        {
                            // Waiting for previous item to finish
                            WaitHandle wh = executorItem.WaitHandle;
                            Log.Info(PROC, "Waiting for previous item to finish for : " + item.UniqueKey);

                            // if shutdown called?
                            if (this.ExecutorService.WaitForShutdown(wh))
                            {
                                Log.Info(PROC, string.Format("Shutdown called. Thread : {0:D} is exiting now.", threadId));
                                break;
                            }

                            // get the signal from the previous item
                            Log.Info(PROC, "Signal got from previous item for : " + item.UniqueKey);
                        }

                        // still have item
                        if (this.ExecutorService.IsShutdown)
                        {
                            Log.Info(PROC, string.Format("Shutdown called. Thread : {0:D} is exiting now.", threadId));
                            break;
                        }

                        // actual processing and processing completion
                        if (!item.Equals(default(T)))
                        {
                            this.OnProcessItem(item);
                            this.OnProcessItemCompleted(executorItem);
                            if (_checkItemCount && (_itemCount > 0))
                            {
                                Interlocked.Decrement(ref _itemCount);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Exception(PROC, ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
            finally
            {
                Log.Info(PROC, string.Format("Shutdown called. Thread : {0:D} has finished his work.", Thread.CurrentThread.ManagedThreadId));
                this.Shutdown();
            }
        }
        /// <summary>
        /// Getting the messages from the queue and process them.
        /// </summary>
        private void ProcessMessagesAsync()
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "ProcessMessagesAsync");
            _startAsyncStatus = InitializeStatus.Completed;
            bool isShutdown = false;
            this.ExecutorService.AddExecutor(this);

            try
            {
                // before process the messages
                try
                {
                    this.OnPreProcessMessagesAsync();
                }
                catch { }

                // actual message processing
                while (!this.ExecutorService.WaitForShutdown(_queueTimeout))
                {
                    GetMessage(out isShutdown);
                }
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }
            finally
            {
                // after process the messages                
                try
                {
                    this.OnPostProcessMessagesAsync();
                }
                catch { /* No Interest to log the message */ }

                this.Shutdown();
            }
        }