コード例 #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;
        }
コード例 #3
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
ファイル: SlackSocket.cs プロジェクト: geluk/SlackAPI
        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
ファイル: CachedPictureBox.cs プロジェクト: seanfuture/Slack
        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();
        }