示例#1
0
        public string[] IterateFiles(string currentPath)
        {
            List <string>          foundFiles = new List <string>();
            LockFreeQueue <string> subPaths   = new LockFreeQueue <string>();

            do
            {
                try
                {
                    string[] subDirectories = Directory.GetDirectories(currentPath);
                    for (int i = 0; i < subDirectories.Length; ++i)
                    {
                        subPaths.Push(subDirectories[i]);
                    }

                    string[] subFiles = Directory.GetFiles(currentPath);
                    foundFiles.AddRange(subFiles);
                }
                catch (Exception)
                {
                    /// We don't care.
                }
            } while (subPaths.Pop(out currentPath));

            return(foundFiles.ToArray());
        }
示例#2
0
        void HandleSending(object stateful)
        {
            string message;

            while (sendingQueue.Pop(out message) && socket.State == WebSocketState.Open && !cts.Token.IsCancellationRequested)
            {
                byte[] sending             = Encoding.UTF8.GetBytes(message);
                ArraySegment <byte> buffer = new ArraySegment <byte>(sending);
                try
                {
                    socket.SendAsync(buffer, WebSocketMessageType.Text, true, cts.Token).Wait();
                }
                catch (WebSocketException wex)
                {
                    if (ErrorSending != null)
                    {
                        ErrorSending(wex);
                    }
                    Close();
                    break;
                }
            }

            currentlySending = 0;
        }
        void UpdateData()
        {
            if (InvokeRequired)
            {
                if (waiting == 1 || Interlocked.CompareExchange(ref writing, 1, 0) == 1)
                {
                    return;
                }

                BeginInvoke(new Action(UpdateData));
                return;
            }

            DataPoint point;

            watch.Restart();
            int count = 0;

            while (queuedPoints.Pop(out point) && watch.ElapsedMilliseconds < 500)
            {
                UpdateData(point);
                ++count;
            }
            this.Invalidate();
            watch.Stop();
            writing = 0;
            if (count != 0)
            {
                waiting = 1;
            }
        }
示例#4
0
        void HandleSending(object stateful)
        {
            string message;

            while (sendingQueue.Pop(out message) && socket.State == WebSocketState.Open)
            {
                socket.Send(message);
            }

            currentlySending = 0;
        }
示例#5
0
        void HandleSending(object stateful)
        {
            string message;

            while (sendingQueue.Pop(out message))
            {
                socket.Send(message);
            }

            currentlySending = 0;
        }
示例#6
0
        static void ExecuteCaching()
        {
            CachedPictureBox currentlyCaching;

            while (cacheQueue.Pop(out currentlyCaching))
            {
                if (cachedImages.ContainsKey(currentlyCaching.Url))
                {
                    currentlyCaching.UpdateCaching();
                    continue;
                }
                Stream data = new Uri(currentlyCaching.Url).DownloadFile();
                cachedImages.Add(currentlyCaching.Url, Image.FromStream(data));
                currentlyCaching.UpdateCaching();
            }

            caching = 0;
        }
示例#7
0
        public string[] IterateFiles(string currentPath)
        {
            List<string> foundFiles = new List<string>();
            LockFreeQueue<string> subPaths = new LockFreeQueue<string>();

            do
            {
                try
                {
                    string[] subDirectories = Directory.GetDirectories(currentPath);
                    for (int i = 0; i < subDirectories.Length; ++i) subPaths.Push(subDirectories[i]);

                    string[] subFiles = Directory.GetFiles(currentPath);
                    foundFiles.AddRange(subFiles);
                }
                catch (Exception)
                {
                    /// We don't care.
                }
            } while (subPaths.Pop(out currentPath));

            return foundFiles.ToArray();
        }