Пример #1
0
        private void RunLoop()
        {
            MessageContext context = null;

            while (true)
            {
                try
                {
                    context = subscriber.Dequeue();
                }
                catch (Exception e)
                {
                    if (!(e is ObjectDisposedException || e is OperationCanceledException))
                    {
                        //TODO: Log exception: Don't know what else to expect here
                    }

                    //Exit method if host has been disposed
                    if (disposed)
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }

                var cancellationToken = CancellationToken.None;
                Task.Factory.StartNew((Func <object, Task>)Process, Tuple.Create(context, cancellationToken), cancellationToken);
            }
        }
Пример #2
0
        private void RunLoop()
        {
            MessageContext context = null;

            while (true)
            {
                try
                {
                    context = subscriber.Dequeue();
                }
                catch (Exception e)
                {
                    if (!(e is ObjectDisposedException))
                    {
                        //TODO: Log exception: Don't know what else to expect here
                    }

                    //Exit method if host has been disposed
                    if (disposed)
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }

                System.Threading.ThreadPool.QueueUserWorkItem(Process, context);
            }
        }