Example #1
0
        private void FlushGroupList()
        {
            IAsyncProcessor ap = Core.ResourceAP;

            if (!ap.IsOwnerThread)
            {
                ap.QueueJob(_priority, _flushGroupListDelegate);
            }
            else
            {
                _groupListLock.Enter();
                try
                {
                    foreach (string group in _groupList)
                    {
                        _serverResource.AddGroup(group);
                    }
                    _groupList.Clear();
                }
                finally
                {
                    _groupListLock.Exit();
                }
            }
        }
Example #2
0
 private void getArticleUnit_Finished(AsciiProtocolUnit unit)
 {
     if (_articleAvailable)
     {
         IAsyncProcessor ap = Core.ResourceAP;
         if (_group == null)
         {
             ap.RunUniqueJob("Creating news article",
                             new CreateArticleByProtocolHandlerDelegate(NewsArticleParser.CreateArticleByProtocolHandler),
                             _lines.ToArray(typeof(string)), _article);
         }
         else
         {
             ap.QueueJob(_priority, "Creating news article",
                         new CreateArticleDelegate(NewsArticleParser.CreateArticle),
                         _lines.ToArray(typeof(string)), _group, _articleId);
         }
     }
     _getArticleUnit = null;
     FireFinished();
 }
Example #3
0
File: Utils.cs Project: mo5h/omeo
        public static void UpdateHttpStatus(IStatusWriter writer, string name, int bytes)
        {
            IAsyncProcessor ap = Core.UserInterfaceAP;

            if (!ap.IsOwnerThread)
            {
                // update status in UI thread, because size formatting requires that
                ap.QueueJob(JobPriority.Immediate,
                            new UpdateHttpStatusDelegate(UpdateHttpStatus), writer, name, bytes);
            }
            else
            {
                bytes &= ~1023;
                StringBuilder builder = StringBuilderPool.Alloc();
                try
                {
                    builder.Append("Downloading ");
                    builder.Append(name);
                    if (bytes == 0)
                    {
                        builder.Append("...");
                    }
                    else
                    {
                        builder.Append(" (");
                        builder.Append(SizeToString(bytes));
                        builder.Append(')');
                    }
                    writer.ShowStatus(builder.ToString());
                }
                finally
                {
                    StringBuilderPool.Dispose(builder);
                }
            }
        }