Пример #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
        public void Send(SlackSocketMessage message)
        {
            if (message.id == 0)
            {
                message.id = Interlocked.Increment(ref currentId);
            }
            //socket.Send(JsonConvert.SerializeObject(message));

            if (message.type == null)
            {
                IEnumerable <SlackSocketRouting> routes = message.GetType().GetCustomAttributes <SlackSocketRouting>();

                SlackSocketRouting route = null;
                foreach (SlackSocketRouting r in routes)
                {
                    route = r;
                }
                if (route == null)
                {
                    throw new InvalidProgramException("Cannot send without a proper route!");
                }
                else
                {
                    message.type    = route.Type;
                    message.subtype = route.SubType;
                }
            }

            sendingQueue.Push(JsonConvert.SerializeObject(message));
            if (Interlocked.CompareExchange(ref currentlySending, 1, 0) == 0)
            {
                ThreadPool.QueueUserWorkItem(HandleSending);
            }
        }
Пример #3
0
        public double this[int i]
        {
            get
            {
                return(values[i]);
            }
            set
            {
                values[i] = value;
                queuedPoints.Push(new DataPoint(i, value));

                UpdateData();//BeginInvoke(new Action<int, double>(UpdateData), i, value);
            }
        }
Пример #4
0
        public CachedPictureBox(string url, int width = 48, int height = 48)
        {
            this.Width  = width;
            this.Height = height;

            this.Url = url;

            if (cachedImages.ContainsKey(url))
            {
                Image = cachedImages[url];
            }
            else
            {
                cacheQueue.Push(this);
                StartCache();
            }
        }
Пример #5
0
        public void Send(SlackSocketMessage message)
        {
            if (message.id == 0)
            {
                message.id = Interlocked.Increment(ref currentId);
            }
            //socket.Send(JsonConvert.SerializeObject(message));

            if (string.IsNullOrEmpty(message.type))
            {
                IEnumerable <SlackSocketRouting> routes = message.GetType().GetTypeInfo().GetCustomAttributes <SlackSocketRouting>();

                SlackSocketRouting route = null;
                foreach (SlackSocketRouting r in routes)
                {
                    route = r;
                }
                if (route == null)
                {
                    throw new InvalidProgramException("Cannot send without a proper route!");
                }
                else
                {
                    message.type    = route.Type;
                    message.subtype = route.SubType;
                }
            }

            sendingQueue.Push(JsonConvert.SerializeObject(message, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));
            if (Interlocked.CompareExchange(ref currentlySending, 1, 0) == 0)
            {
                Task.Factory.StartNew(HandleSending);
            }
        }
Пример #6
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();
        }