Пример #1
0
        public void StartThreading()
        {
            _threadCount++;
            Thread thread = new Thread(() =>
            {
                DownloadTask task = null;
                do
                {
                    bool didFind = _tasks.TryDequeue(out task);
                    if (!didFind)
                    {
                        break;
                    }

                    Bitmap bitmap = task.Download();
                    if (bitmap != null)
                    {
                        if (UseCache)
                        {
                            Cache(task.Url, bitmap);
                        }
                        task.Load(bitmap);
                    }
                }while (task != null);
                lock (lck)
                {
                    _threadCount--;
                }
            });

            thread.Start();
        }