public void ShouldCallbackOnCommand() { ThreadCommand.OnExecute += new OnExecuteDelegate(ThreadCommand_OnExecute); ThreadQueue<ThreadCommand> threadQueue = new ThreadQueue<ThreadCommand>(); TestObject test = new TestObject(); test.TestString = "Hello World"; threadQueue.Enqueue(test); _resetEvent.WaitOne(); threadQueue.Dispose(); }
public SocketComm(Socket s, bool clientSide, string socketAlias) { ShouldBeRunning = true; DataToSendQueue = new ThreadQueue<byte[]>(); socket = s; inputThread = new Thread(new ThreadStart(inputWorker)); outputThread = new Thread(new ThreadStart(outputWorker)); inputProcThread = new Thread(new ThreadStart(inputProcWorker)); if (clientSide) { inputThread.Name = "Client Socket Input Worker (" + socketAlias + ")"; outputThread.Name = "Client Socket Input Worker (" + socketAlias + ")"; } else { inputThread.Name = "Server Socket Input Worker (" + socketAlias + ")"; outputThread.Name = "Server Socket Input Worker (" + socketAlias + ")"; } inputThread.Start(); outputThread.Start(); inputProcThread.Start(); }
private void ReleaseQuery(ThreadQueue.TaskControl control, object state) { try { if( db != null ) { ReleaseState rlState = state as ReleaseState; rlState.Query.Release(); } else { throw new Exception( "Database not ready!" ); } } catch (Exception ex) { Debug.LogError("SQLiteAsync : Exception : " + ex.Message); } }
private void StepQuery(ThreadQueue.TaskControl control, object state) { try { if( db != null ) { StepState stState = state as StepState; stState.Step = stState.Query.Step(); } else { throw new Exception( "Database not ready!" ); } } catch (Exception ex) { Debug.LogError("SQLiteAsync : Exception : " + ex.Message); } }
private void CreateQuery(ThreadQueue.TaskControl control, object state) { try { if( db != null ) { QueryState qrState = state as QueryState; qrState.Query = new SQLiteQuery(db,qrState.Sql); } else { throw new Exception( "Database not ready!" ); }/**/ } catch (Exception ex) { Debug.LogError("SQLiteAsync : CreateQuery : Exception : " + ex.Message); } }
private void CloseDatabase(ThreadQueue.TaskControl control, object state) { try { if( db != null ) { db.Close(); db = null; } else { throw new Exception( "Database not ready!" ); } } catch (Exception ex) { Debug.LogError("SQLiteAsync : Exception : " + ex.Message); } }
// // functions // private void OpenDatabase(ThreadQueue.TaskControl control, object state) { OpenState opState = state as OpenState; try { db = new SQLiteDB(); db.Open(opState.Filename); opState.Succeed = true; } catch (Exception ex) { opState.Succeed = false; Debug.LogError("SQLiteAsync : OpenDatabase : Exception : " + ex.Message); } }
void OnDestroy() { if( thread != null ) thread.Terminate(); // clean up global value instance = null; initialized = false; }
void compareFiles(int progress) { if (bitmaps == null) return; comparisions = new Dictionary<ComparableBitmap, List<ComparableBitmap>>(); processed = new List<int>(); double p = 0; for (int i = 0; i < bitmaps.Count; i++) { if (bw.CancellationPending) break; if (!processed.Contains(i) && !comparisions.ContainsKey(bitmaps[i])) { comparisions.Add(bitmaps[i], new List<ComparableBitmap>()); processed.Add(i); ThreadQueue q = new ThreadQueue(bitmaps.Count / 10); Levenshtein alg = new Levenshtein(); for (int j = 0; j < bitmaps.Count; j++) { if (bw.CancellationPending) break; q.QueueUserWorkItem((WaitCallback)delegate(object a) { int r = (int)a; if (i != r && !processed.Contains(r)) { int k = alg.GetDistance<byte>(bitmaps[i], bitmaps[r]); if (k <= Settings.Default.SimilarityTreshold) { bitmaps[r].Similarity = k; comparisions[bitmaps[i]].Add(bitmaps[r]); processed.Add(r); if (OnNewDuplicateFound != null) { OnNewDuplicateFound(this, null); } } } }, j); bw.ReportProgress((int)(++p / (double)(bitmaps.Count * bitmaps.Count) * 100), string.Format(Resources.strProceessing, bitmaps[i].Path.Substring(bitmaps[i].Path.LastIndexOf('\\')+1))); } q.WaitAll(); } } }
public WindowsProcessWatcher(IActivityMonitor monitor, ThreadQueue<TickInfo> queue) { this.monitor = monitor; this.queue = queue; }
// // functions // private void OpenDatabase(ThreadQueue.TaskControl control, object obj) { string filename = obj as string; try { db = new SQLiteDB(); db.Open(filename); } catch (Exception ex) { Debug.LogError("SQLiteAsync : OpenDatabase : Exception : " + ex.Message); } }