예제 #1
0
        public void SendFile(string path, Tuple <FileProcessedHandler, object> processed)
        {
            if (Core.InvokeRequired)
            {
                Core.RunInCoreAsync(() => SendFile(path, processed));
                return;
            }

            // add to share list
            SharedFile file = new SharedFile(Core.Network.Local.ClientID);

            file.Name       = Path.GetFileName(path);
            file.SystemPath = path;

            file.Completed = true;
            file.Sources.Add(Core.Network.Local);
            file.FileStatus = "Processing...";
            file.Processed  = processed;

            // so user can see hash progress
            Local.Files.SafeAdd(file);
            Core.RunInGuiThread(GuiFileUpdate, file);

            ProcessFiles.Enqueue(() => ProcessFile(file));
        }
예제 #2
0
        /// <remarks>
        /// This method is thread safe.
        /// </remarks>
        public void QueueSync(ChatModel chatModel)
        {
            Trace.Call(chatModel);

            if (chatModel == null)
            {
                throw new ArgumentNullException("chatModel");
            }

            WorkerQueue.Enqueue(delegate {
                SyncWorker(chatModel);
            });
        }
예제 #3
0
        public void MarkforHash(LocalFile file, string path, uint project, string dir)
        {
            HashPack pack = new HashPack(file, path, project, dir);

            lock (HashFiles.Pending)
                if (HashFiles.Pending.Any(p => ((HashPack)p.Param2).File == file))
                {
                    return;
                }

            file.Info.Size = new FileInfo(path).Length; // set so we can get hash status

            HashFiles.Enqueue(() => HashFile(pack), pack);
        }
예제 #4
0
        public void OpenFile(ulong user, SharedFile file)
        {
            if (!File.Exists(GetFilePath(file)))
            {
                return;
            }

            // check if already exists, if it does open
            if (file.SystemPath != null && File.Exists(file.SystemPath))
            {
                Process.Start(file.SystemPath);
                return;
            }

            OpenFiles.Enqueue(() => OpenFile(file));
        }
예제 #5
0
        /// <remarks>
        /// This method is thread safe.
        /// </remarks>
        public void QueueAdd(ChatModel chatModel)
        {
            Trace.Call(chatModel);

            if (chatModel == null)
            {
                throw new ArgumentNullException("chatModel");
            }

            var chatKey = GetChatKey(chatModel);

            lock (SyncWaitQueue) {
                SyncWaitQueue.Add(chatKey, new AutoResetEvent(false));
#if LOG4NET
                Logger.Debug("QueueAdd() <" + chatKey + "> created sync lock");
#endif
            }
            WorkerQueue.Enqueue(delegate {
                AddWorker(chatModel);
            });
        }
        private void rasterizeChunk(Chunk chunk)
        {
            float distance = player.GetDistance(chunk.Position);

            renderQueue.Enqueue(distance, new RasterizeWorker(chunk));
        }
        private void generateChunk(Chunk chunk)
        {
            float distance = player.GetDistance(chunk.Position);

            generateQueue.Enqueue(distance, new GenerateWorker(chunk, world));
        }
예제 #8
0
 public IActionResult Calculate(Calculation calculation)
 {
     workerQueue.Enqueue((token) => CalculateInternal(calculation));
     return(Ok());
 }
예제 #9
0
 public void Write(LogContent logDoc)
 {
     _localLogQueue.Enqueue(logDoc);
 }