/// <summary> /// Makes async request to checker with random line /// </summary> /// <param name="checker">FileLinesCheckerBase</param> private static void AsyncRequest(Object @object) { FileLinesCheckerBase checker = @object as FileLinesCheckerBase; checker.ContainsAsync(GetSomeLine(), ShowSuccessResultFromAsync, ShowFailureResultFromAsync); }
/// <summary> /// Call to FileLinesCheckerBase.Cancel /// </summary> /// <param name="object">FileLinesCheckerBase as object</param> private static void CancelChecker(Object @object) { FileLinesCheckerBase checker = @object as FileLinesCheckerBase; Console.WriteLine("Cancel call!"); checker.Cancel(); }
/// <summary> /// Call to FileLinesCheckerBase.Reset /// </summary> /// <param name="object">FileLinesCheckerBase as object</param> private static void ResetChecker(Object @object) { FileLinesCheckerBase checker = @object as FileLinesCheckerBase; Console.WriteLine("Reset call!"); checker.Reset(); }
/// <summary> /// Makes sync request to checker with random line /// </summary> /// <param name="checker">FileLinesCheckerBase</param> private static void SyncRequest(Object @object) { FileLinesCheckerBase checker = @object as FileLinesCheckerBase; try { Console.WriteLine(" Sync done: Thread={0}, Result={1}", Thread.CurrentThread.ManagedThreadId, checker.Contains(GetSomeLine())); } catch (Exception exception) { Console.WriteLine(" Sync fail: Thread={0}, Exception={1}", Thread.CurrentThread.ManagedThreadId, exception.Message); } }
/// <summary> /// Call to FileLinesCheckerBase.Cancel from new thread /// </summary> /// <param name="checker">FileLinesCheckerBase</param> private static void CancelAsync(FileLinesCheckerBase checker) { ThreadPool.QueueUserWorkItem(CancelChecker, checker); }
/// <summary> /// Makes sync request to checker with random line from new thread /// </summary> /// <param name="checker">FileLinesCheckerBase</param> private static void AsyncSyncRequest(FileLinesCheckerBase checker) { ThreadPool.QueueUserWorkItem(SyncRequest, checker); }
/// <summary> /// Call to FileLinesCheckerBase.Reset from new thread /// </summary> /// <param name="checker"></param> private static void ResetAsync(FileLinesCheckerBase checker) { ThreadPool.QueueUserWorkItem(ResetChecker, checker); }