public static int Main() { Thread t1 = new Thread(new ThreadStart (MultiThreadExceptionTest.ThreadStart1)); t1.Name = "Thread 1"; Thread.Sleep (100); t1.Start(); Thread.Sleep (200); t1.Abort ("STATETEST"); t1.Join (); Console.WriteLine ("Result: " + result); if (result != 27) return 1; return 0; }
public void Start() { try { //Starting the TCP Listener thread. sampleTcpThread = new Thread(new ThreadStart(StartListen2)); sampleTcpThread.Start(); Console.Message = ("Started SampleTcpUdpServer's TCP Listener Thread!\n"); OnChanged(EventArgs.Empty); } catch (Exception e) { Console.Message = ("An TCP Exception has occurred!" + e); OnChanged(EventArgs.Empty); sampleTcpThread.Abort(); } try { //Starting the UDP Server thread. sampleUdpThread = new Thread(new ThreadStart(StartReceiveFrom2)); sampleUdpThread.Start(); Console.Message = ("Started SampleTcpUdpServer's UDP Receiver Thread!\n"); OnChanged(EventArgs.Empty); } catch (Exception e) { Console.Message = ("An UDP Exception has occurred!" + e); OnChanged(EventArgs.Empty); sampleUdpThread.Abort(); } }
static void Main(string[] args) { //Declarations ConsoleKey ck; Thread thSniffer; //Create the sniffer thread thSniffer = new Thread(new ThreadStart(Sniffer.GetSniffer().Start)); //Start sniffing thSniffer.Start(); Console.WriteLine("Press Enter key to quit anytime..."); Console.WriteLine(); //Read the console ck = Console.ReadKey().Key; //Shutdown the sniffer if the user opted to if (ck == ConsoleKey.Enter) { Sniffer.GetSniffer().ShutDown(); thSniffer.Abort(); } }
/// <summary> /// Do our best to kill a thread, passing state info /// </summary> /// <param name="thread">The thread to kill</param> /// <param name="stateInfo">Info for the ThreadAbortException handler</param> public static void Kill(Thread thread, object stateInfo) { try { if (stateInfo == null) thread.Abort(); else thread.Abort(stateInfo); } catch (ThreadStateException) { #if !NETCF // Although obsolete, this use of Resume() takes care of // the odd case where a ThreadStateException is received. #pragma warning disable 0618,0612 // Thread.Resume has been deprecated thread.Resume(); #pragma warning restore 0618,0612 // Thread.Resume has been deprecated #endif } #if !NETCF if ( (thread.ThreadState & ThreadState.WaitSleepJoin) != 0 ) thread.Interrupt(); #endif }
public TcpClient Connect() { // kick off the thread that tries to connect connected = false; exception = null; Thread thread = new Thread(new ThreadStart(BeginConnect)); thread.IsBackground = true; // So that a failed connection attempt // wont prevent the process from terminating while it does the long timeout thread.Start(); // wait for either the timeout or the thread to finish thread.Join(_timeout_milliseconds); if (connected == true) { // it succeeded, so return the connection thread.Abort(); return connection; } if (exception != null) { // it crashed, so return the exception to the caller thread.Abort(); throw exception; } else { // if it gets here, it timed out, so abort the thread and throw an exception thread.Abort(); string message = string.Format("TcpClient connection to {0}:{1} timed out", _hostname, _port); throw new TimeoutException(message); } }
public static bool Connect(Socket s, IPEndPoint ep, int timeOutmiliSeconds) { _connected = false; var registerThread = new Thread(() => SockConnect(s, ep)) { Priority = ThreadPriority.Normal }; registerThread.Start(); int timeout = 0; while (registerThread.IsAlive) { if (_connected) { registerThread.Abort(); return true; } Thread.Sleep(100); if (++timeout == timeOutmiliSeconds / 100) { while (_killwait) { ; } registerThread.Abort(); return false; } } return _connected; }
public TcpClient Connect() { connected = false; exception = null; Thread thread = new Thread(new ThreadStart(BeginConnect)); thread.IsBackground = true; thread.Start(); thread.Join(_timeout_milliseconds); if (connected == true) { thread.Abort(); return connection; } if (exception != null) { // it crashed, so return the exception to the caller thread.Abort(); return connection; //throw exception; } else { // if it gets here, it timed out, so abort the thread and throw an exception thread.Abort(); string message = string.Format("TcpClient connection to {0}:{1} timed out", _hostname, _port); //throw new TimeoutException(message); return connection; } }
/// <summary> /// Return a list of file locks held by the process. /// </summary> public static List<string> GetFilesLockedBy(Process process) { var outp = new List<string>(); ThreadStart ts = delegate { try { outp = UnsafeGetFilesLockedBy(process); } catch { Ignore(); } }; var t = new Thread(ts); t.IsBackground = true; try { t.Start(); if (!t.Join(250)) { try { t.Interrupt(); t.Abort(); } catch { t.Abort(); } } } catch { t.Abort(); } return outp; }
/// <summary> /// HTTP通信 /// </summary> /// <param name="JSONstring"></param> /// <returns></returns> public static bool HttpConnect(string JSONstring) { JSON = JSONstring; HttpWebRequest request = null; HttpWebResponse response = null; int lastTime = 0; //网络请求线程 Thread requestThread = new Thread(delegate() { WaitForConnection(out request); }); requestThread.Start(); //通过持续时间判断网络是否异常 lastTime = System.DateTime.Now.Millisecond + System.DateTime.Now.Second * 1000; while(requestThread .IsAlive) { if(System.DateTime.Now.Millisecond+System.DateTime.Now.Second*1000-lastTime<0) { lastTime = System.DateTime.Now.Millisecond + System.DateTime.Now.Second * 1000; } else if(System.DateTime.Now.Millisecond+System.DateTime.Now.Second*1000-lastTime>2000) { Debug.Log("Request Lost!"); requestThread.Abort(); return false; } } //网络回应线程 Thread responseThread = new Thread(delegate() { WaitForResponse(request, response); }); responseThread.Start(); //通过持续时间判断网络是否异常 lastTime = System.DateTime.Now.Millisecond + System.DateTime.Now.Second * 1000 - lastTime; while(responseThread .IsAlive ) { if (System.DateTime.Now.Millisecond + System.DateTime.Now.Second * 1000 - lastTime < 0) { lastTime = System.DateTime.Now.Millisecond + System.DateTime.Now.Second * 1000; } else if (System.DateTime.Now.Millisecond + System.DateTime.Now.Second * 1000 - lastTime > 2000) { Debug.Log("Request Lost!"); requestThread.Abort(); return false; } } return true; }
public static void ForceStop(ref Thread thread, bool setNull) { try { if (thread != null && thread.IsAlive) { //force stop try { thread.Interrupt(); } catch (ThreadInterruptedException ex) { Log.WarnFormat("thread {0} Interrupt error : {1}", thread.Name, ex.Message); try { thread.Abort(); } catch (System.Exception ex1) { Log.WarnFormat("thread {0} Abort error : {1}", thread.Name, ex1.Message); } } catch (System.Exception ex) { Log.WarnFormat("thread {0} Interrupt error : {1}", thread.Name, ex.Message); try { thread.Abort(); } catch (System.Exception ex1) { Log.WarnFormat("thread {0} Abort error : {1}", thread.Name, ex1.Message); } } finally { if (setNull) { thread = null; } } } else { if (setNull) { thread = null; } } } catch (System.Exception ex) { Log.Error("Not expectant exception : ", ex); throw ex; } }
public void Thread_wont_die() { var t = new Thread(IWillNotDie); t.Start(); Thread.Sleep(1000); t.Abort(); Thread.Sleep(1000); t.Abort(); Thread.Sleep(1000); t.Abort(); Assert.That(t.ThreadState == ThreadState.Running); }
static void Main(string[] args) { Console.WriteLine("Thread Start/Stop/Join Sample"); Alpha oAlpha = new Alpha(); //这里创建一个线程,使之执行Alpha类的Beta()方法 Thread oThread = new Thread(new ThreadStart(oAlpha.Beta)); oThread.Start(); while (!oThread.IsAlive) Thread.Sleep(1); oThread.Abort(); oThread.Join(); Console.WriteLine(); Console.WriteLine("Alpha.Beta has finished"); try { Console.WriteLine("Try to restart the Alpha.Beta thread"); oThread.Start(); } catch (ThreadStateException) { Console.Write("ThreadStateException trying to restart Alpha.Beta. "); Console.WriteLine("Expected since aborted threads cannot be restarted."); Console.ReadLine(); } return; }
public Bitmap GetBitmapFromWeb(string url) { mre = new ManualResetEvent(false); Thread t = new Thread(new ParameterizedThreadStart(BitmapThreadWorker)); t.SetApartmentState(ApartmentState.STA); t.Start(url); if (!mre.WaitOne(s_RequestTimeout / 2, false)) t.Abort(); if (!t.Join(s_RequestTimeout / 2)) t.Abort(); return bmp; }
public void TcpSynchronousAcceptanceTest() { bool serverGood = false; Thread serverThread = new Thread(() => { ServerThread(x => serverGood = x); }); bool clientGood = false; Thread clientThread = new Thread(() => { ClientThread(x => clientGood = x); }); clientThread.Start(); serverThread.Start(); //Sleep to allow the threads a chance to die bool serverCompleted = serverThread.Join(5000); bool clientCompleted = clientThread.Join(5000); if (!(serverCompleted && clientCompleted)) { //Politely ask both threads to stop before main thread dies and hard-aborts them serverThread.Abort(); clientThread.Abort(); Assert.Fail("The threads never returned in the join"); } else { Assert.IsTrue(clientGood && serverGood, "The client and server thread should have both been good"); } }
///<summary></summary> public static void SendData(Program ProgramCur,Patient pat) { _path=Programs.GetProgramPath(Programs.GetCur(ProgramName.DemandForce)); if(!File.Exists(_path)) { MessageBox.Show(_path+" could not be found."); return; } if(MessageBox.Show(Lan.g("DemandForce","This may take 20 minutes or longer")+". "+Lan.g("DemandForce","Continue")+"?","",MessageBoxButtons.OKCancel)!=DialogResult.OK) { return; } _formProg=new FormProgress(); _formProg.MaxVal=100; _formProg.NumberMultiplication=1; _formProg.DisplayText=""; _formProg.NumberFormat="F";//Show whole percentages, not fractional percentages. Thread workerThread=new Thread(new ThreadStart(InstanceBridgeExport)); workerThread.Start(); if(_formProg.ShowDialog()==DialogResult.Cancel) { workerThread.Abort(); MessageBox.Show(Lan.g("DemandForce","Export cancelled")+". "+Lan.g("DemandForce","Partially created file has been deleted")+"."); CheckCreatedFile(CodeBase.ODFileUtils.CombinePaths(Path.GetDirectoryName(_path),"extract.xml")); _formProg.Dispose(); return; } MessageBox.Show(Lan.g("DemandForce","Export complete")+". "+Lan.g("DemandForce","Press OK to launch DemandForce")+"."); try { Process.Start(_path);//We might have to add extract.xml to launch command in the future. } catch { MessageBox.Show(_path+" is not available."); } _formProg.Dispose(); }
public void Cancel() { if (Interlocked.Exchange(ref _awaitsResolution, 0) == 1) { _thread?.Abort(); } }
private static void F2() { Thread t2 = new Thread(new ParameterizedThreadStart(doit2)); t2.Start(); string line = Console.ReadLine(); t2.Abort(); }
public static void Main(string[] args) { Menu menu = new Menu(); Console.Title = " PhDD"; Thread hddMonitor = new Thread(new ThreadStart(menu.Run)); if (Menu.getAccessLvl()) { hddMonitor.Start(); } bool exit = false; string input = ""; while (!exit) { Console.Write("PhDD >"); input = Console.ReadLine(); switch (input.ToLower()) { case "exit": { hddMonitor.Abort(); exit = true; break; } case "help": { menu.displayMenuHelp(); break; } case "clear": { Console.Clear(); break; } } } }
private void BtnLogin_Click(object sender, EventArgs e) { try { Usuarios us = new Usuarios( TxtLogin.Text , TxtPassword.Text ); if ( us.Existe ) { new Parser( ).InitValues( us.Privilegios ); Hide( ); Thread thread = new Thread( new ThreadStart( Splash ) ); thread.Start( ); Thread.Sleep( 6000 ); thread.Abort( ); Injector.Link main = new Injector.Link( us ); ConexionBD.UsuarioActual = us; } else { MessageBox.Show( "El Login y/o el Password son incorrectos" , "Atención" , MessageBoxButtons.OK , MessageBoxIcon.Information ); } } catch ( Exception ex) { log.Error( ex.Message , ex ); alertControl.Show( this , "Hubo un error" , ex.Message , Image ); MessageBox.Show( ex.Message ); } }
/// <summary> /// Enumerates all top level windows on desktop. WARNING: The method returns null if operation timeout is reached. /// </summary> /// <param name="milliSecondsTimeout">a timeout for the operation. when a desktop is busy or non responding these method freeze. you can handle this with the operation timeout</param> /// <returns>Result Array or null</returns> public IntPtr[] EnumerateWindows(int milliSecondsTimeout) { try { lock (_lockInstance) { Result.Clear(); _currentInstance = this; Thread thread1 = new Thread(new ParameterizedThreadStart(EnumerateWindowsAsync)); WaitHandle[] waitHandles = new WaitHandle[1]; ManualResetEvent mre1 = new ManualResetEvent(false); waitHandles[0] = mre1; thread1.Start(mre1); bool result = WaitHandle.WaitAll(waitHandles, milliSecondsTimeout); if (!result) { thread1.Abort(); Result.Clear(); _currentInstance = null; return null; } else { _currentInstance = null; } } return Result.ToArray(); } catch (Exception exception) { DebugConsole.Default.WriteException(exception); throw; } }
public static void Main() { Master_Controls controls = new Master_Controls(); Thread appThread = new Thread(new ThreadStart(controls.ApplicationThread)); appThread.Start(); //wait until UI Window is created _autoEvent.WaitOne(); Thread.Sleep(500); string[] args = {"BorderTests", "CanvasTests","StackPanelTests", "TextTests", "PanelTests", "ImageTests", "TextFlowTests", "ScrollViewerTests", "ListBoxTests"}; MFTestRunner runner = new MFTestRunner(args); Log.Comment("Aborting the Application Thread"); try { controls.app.Dispatcher.Invoke(new TimeSpan(0, 0, 5), new DispatcherOperationCallback(controls.ShutDownApp), null); appThread.Abort(); } catch (Exception ex) { Log.Comment("Caught : " + ex.Message + " when aborting the application thread"); } }
public BasicConsole(bool colorful) { _output = System.Console.Out; _errorOutput = System.Console.Error; SetupColors(colorful); _creatingThread = Thread.CurrentThread; #if !SILVERLIGHT // ConsoleCancelEventHandler // Create the default handler this.ConsoleCancelEventHandler = delegate(object sender, ConsoleCancelEventArgs e) { if (e.SpecialKey == ConsoleSpecialKey.ControlC) { e.Cancel = true; _ctrlCEvent.Set(); _creatingThread.Abort(new KeyboardInterruptException("")); } }; Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) { // Dispatch the registered handler ConsoleCancelEventHandler handler = this.ConsoleCancelEventHandler; if (handler != null) { this.ConsoleCancelEventHandler(sender, e); } }; #endif _ctrlCEvent = new AutoResetEvent(false); }
public static byte[] CaptureWebPageBytes(string body, int width, int height) { bool bDone = false; byte[] data = null; DateTime startDate = DateTime.Now; DateTime endDate = DateTime.Now; //sta thread to allow intiate WebBrowser var staThread = new Thread(delegate() { data = CaptureWebPageBytesP(body, width, height); bDone = true; }); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(); while (!bDone) { endDate = DateTime.Now; TimeSpan tsp = endDate.Subtract(startDate); System.Windows.Forms.Application.DoEvents(); if (tsp.Seconds > 50) { break; } } staThread.Abort(); return data; }
public static void Start() { Log.Info("Starting RconHandler."); try { Console.WriteLine(string.Format("RconHandler is running at UDP port {0} and password is {1}", ListenPort, Password)); listen = new Thread(Listener); listen.Start(); while (true) { if (listen.ThreadState != ThreadState.Running) { listen.Abort(); while (listen.ThreadState != ThreadState.Stopped) continue; listen.Start(); } Thread.Sleep(3000); } } catch (Exception e) { Log.Error(e.ToString()); } }
/// <summary> /// Tests the caching and re using of sessiosn to increase perfomance by avoding /// creating new sessions for each client request /// </summary> // [Test] public void CachedSessionTest() { ServerClientSession lSession = GetCachedSession(); //lets simulate that we did some prior work, return the session and get it again ReturnSessionToCache(lSession); lSession = GetCachedSession(); TestClass lTestClass = new TestClass(); lTestClass.SomeIntVar = 123; lTestClass.SomeStringVar = "test"; lTestClass.Persist(lSession, lTestClass); lSession.Commit(); //return to cache, get it again and query the object //as this test is to verify it does not hang we do it in separate therad and kill after timeout ReturnSessionToCache(lSession); Thread lThread=new Thread(new ThreadStart(()=> { lSession = GetCachedSession(); counter = lSession.AllObjects<TestClass>(true, false).Count(); ReturnSessionToCache(lSession); })); lThread.Start(); lEvent.WaitOne(5000); if(lThread.IsAlive)lThread.Abort(); Assert.AreNotEqual(0, counter, "Invalid nr of objects retreived"); }
public void createClient(short portNumber) { ClientInit init = new ClientInit(); init.newClientInit(); mainClient = new TcpClient(); mainClient.Connect(init.hostAddr , portNumber); NetworkStream nStream = mainClient.GetStream(); usrData.userID = init.serverHandshake(nStream, encoding); mThread = new Thread(messageThread); mThread.Start(nStream); byte[] buffer; string message; Console.SetCursorPosition(0, 21); while ((message = Console.ReadLine()) != "!exit") { buffer = encoding.GetBytes(message); nStream.Write(buffer, 0, message.Length); nStream.Flush(); updateMessages(string.Format("me: {0}", message)); message = ""; clearConsoleLines(1, 21); Console.SetCursorPosition(0, 21); } mThread.Abort(); mainClient.Close(); }
static void Main(string[] args) { ThreadSample sample = new ThreadSample(); ThreadStart tsa = new ThreadStart(sample.ThreadFuncA); ThreadStart tsb = new ThreadStart(sample.ThreadFuncB); Thread ta = new Thread(tsa); Thread tb = new Thread(tsb); // A 线程的 优先级 高于 B 线程 // 在线程代码的 计数 中,A线程的 数值要大于 B线程。 ta.Priority = ThreadPriority.Highest; tb.Priority = ThreadPriority.Lowest; // 启动. ta.Start(); tb.Start(); // 执行5秒以后, 结束 Thread.Sleep(5000); ta.Abort(); tb.Abort(); Console.ReadLine(); }
static void RunWithTimeout(Action entryPoint, int timeout) { Thread thread = null; try { thread = new Thread(() => entryPoint()) { IsBackground = true }; if (thread != null) { thread.Start(); if(thread.IsAlive) thread.Join(timeout); } } catch (Exception ex) { ddbs.WriteErrorMessage(ddbs.ConnectionString, 0, null, "ошибка запуска задания " + ex.Message,-1); } finally { if (thread != null) thread.Abort(); if (thread != null) thread.Join(3000); if (thread != null) thread.Interrupt(); if (thread != null) GC.SuppressFinalize(thread); }; thread = null; }
static int Main (string[] args) { Thread t = new Thread (new ThreadStart (Run)); t.Start (); Thread.Sleep (100); t.Abort (); return 0; }
/// <summary> /// Main method /// </summary> /// <param name="args">(unused)</param> static void Main(string[] args) { Console.CursorVisible = false; Console.Title = "Mastermind RPG - By Steven Sucy"; // Display the logo upon startup Constants.Load(); ConsoleTools.DrawDesign(ConsoleTools.logo); Console.ReadKey(); string choice = ""; Thread thread = new Thread(() => KeyInput.ThreadMethod()); thread.Start(); do { // If there was an input already that didn't exit the // loop, execute it if (choice.Length != 0) MastermindRPG.Actions.Action.Execute(choice); // Display the main menu MainMenu mainMenu = new MainMenu(); choice = mainMenu.Show(); } while (!choice.Equals("Quit") && !choice.Equals("")); Console.Clear(); thread.Abort(); }
static void Main(string[] args) { UdpNotifierCacheDependency dependency = new UdpNotifierCacheDependency(); ObjectCacheQueue.Instance.Add("ClientData", string.Empty, dependency); object oldCacheData = ObjectCacheQueue.Instance["ClientData"]; Console.Title = "UdpCacheDependency测试Chat"; Console.WriteLine("Please input text..."); Thread thread = new Thread((ThreadStart)MonitorThread); thread.Start(); string cmd = Console.ReadLine(); while (cmd.ToLower() != "exit") { if (cmd.IsNotEmpty()) { if (cmd.ToLower() == "send100") SendOneHundredMessages(); else SendOneMessage(cmd); } cmd = Console.ReadLine(); } thread.Abort(); thread.Join(); }
/// <summary> /// Stops this instance. /// </summary> public virtual void Stop() { if (IsEnabled == false || IsRunning == false) { return; } "Stop Requested".Debug(Name); _cancelTokenSource?.Cancel(); var waitRetries = 5; while (waitRetries >= 1) { if (_workFinished?.WaitOne(250) ?? true) { waitRetries = -1; break; } waitRetries--; } if (waitRetries < 0) { "Workbench stopped gracefully".Debug(Name); } else { "Did not respond to stop request. Aborting thread and waiting . . .".Warn(Name); _worker?.Abort(); if (_workFinished?.WaitOne(5000) == false) { "Waited and no response. Worker might have been left in an inconsistent state.".Error(Name); } else { "Waited for worker and it finally responded (OK).".Debug(Name); } } _workFinished?.Dispose(); _workFinished = null; }
public void Dispose() { subscriptionThread?.Abort(); subscriptionThread = null; if (subscriptionListener != null) { subscriptionListener.ServerEventReceived -= _eventHandler.Invoke; subscriptionListener.Dispose(); subscriptionListener = null; } subscription?.Dispose(); subscription = null; workingTaskCancellationTokenSource?.Cancel(); workingTaskCancellationTokenSource?.Dispose(); workingTaskCancellationTokenSource = null; isListening = false; }
private void StopDirWatcher() { try { direcoryWatcherlog?.StopWatcher(); } catch { } try { dirWatcherThread?.Abort(); } catch { } }
private void PoeSmoother_Closing(object sender, System.ComponentModel.CancelEventArgs e) { workerThread?.Abort(); }
public void Dispose() { _watcher?.Dispose(); _consumerThread?.Abort(); }
private void OperationState_StateChanged(object sender, OperationStateChangedEventArgs e) { try { if (e.State == TestOperationStates.TestExecutionStarting) { try { _reloadCoverageThread?.Abort(); } catch { // ignore } finally { _reloadCoverageThread = null; FCCEngine.ClearProcesses(); } } if (e.State == TestOperationStates.TestExecutionFinished) { var settings = AppOptions.Get(); if (!settings.Enabled) { FCCEngine.CoverageLines.Clear(); UpdateMarginTags?.Invoke(this, null); UpdateOutputWindow?.Invoke(this, null); return; } Logger.Log("================================== START =================================="); var operationType = e.Operation.GetType(); var darkMode = CurrentTheme.Equals("Dark", StringComparison.OrdinalIgnoreCase); var testConfiguration = (operationType.GetProperty("Configuration") ?? operationType.GetProperty("Configuration", BindingFlags.Instance | BindingFlags.NonPublic)).GetValue(e.Operation); var testContainers = ((IEnumerable <object>)testConfiguration.GetType().GetProperty("Containers").GetValue(testConfiguration)).ToArray(); var projects = new List <CoverageProject>(); foreach (var container in testContainers) { var project = new CoverageProject(); var containerType = container.GetType(); var containerData = containerType.GetProperty("ProjectData").GetValue(container); var containerDataType = containerData.GetType(); project.ProjectGuid = containerType.GetProperty("ProjectGuid").GetValue(container).ToString(); project.ProjectName = containerType.GetProperty("ProjectName").GetValue(container).ToString(); project.TestDllFileInOutputFolder = containerType.GetProperty("Source").GetValue(container).ToString(); project.TestDllCompilationMode = AssemblyUtil.GetCompilationMode(project.TestDllFileInOutputFolder); project.ProjectFile = containerDataType.GetProperty("ProjectFilePath", BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.NonPublic).GetValue(containerData).ToString(); var defaultOutputFolder = Path.GetDirectoryName(containerDataType.GetProperty("DefaultOutputPath", BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.NonPublic).GetValue(containerData).ToString()); project.WorkFolder = Path.Combine(Path.GetDirectoryName(defaultOutputFolder), "fine-code-coverage"); projects.Add(project); } _reloadCoverageThread = new Thread(() => { try { // compute coverage FCCEngine.ReloadCoverage(projects.ToArray(), darkMode); // update margins { UpdateMarginTagsEventArgs updateMarginTagsEventArgs = null; try { updateMarginTagsEventArgs = new UpdateMarginTagsEventArgs { }; } catch { // ignore } finally { UpdateMarginTags?.Invoke(this, updateMarginTagsEventArgs); } } // update output window { UpdateOutputWindowEventArgs updateOutputWindowEventArgs = null; try { updateOutputWindowEventArgs = new UpdateOutputWindowEventArgs { HtmlContent = File.ReadAllText(FCCEngine.HtmlFilePath) }; } catch { // ignore } finally { UpdateOutputWindow?.Invoke(this, updateOutputWindowEventArgs); } } // log Logger.Log("================================== DONE ==================================="); } catch (Exception exception) { if (!(exception is ThreadAbortException) && _reloadCoverageThread != null) { Logger.Log("Error", exception); Logger.Log("================================== ERROR =================================="); } } }); _reloadCoverageThread.Start(); } } catch (Exception exception) { Logger.Log("Error processing unit test events", exception); } }
private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { gameAccess?.Abort(); }
public void Stop() { main?.Abort(); }
public void StopQuiz() { moduleConnector.AbortListener(); waitThread?.Abort(); }
public void StopCycle() { _requestThread?.Abort(); _requestThread = null; }
private void Stop() { _signalThread?.Abort(); _signalThread = null; }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { receiveMessageThread?.Abort(); }
public void Stop() { updateThread?.Abort(); updateThread = null; starMapService = null; }
public void Stop() { //Harter Stopp _thread?.Abort(); _cts?.Cancel(); }
//przycisk Zatrzymaj private void button3_Click(object sender, EventArgs e) { tp?.Abort(); tk?.Abort(); }
private void StopSend() { running = false; sendThread?.Abort(); }
public void Dispose() { ConsumerThread?.Abort(); }
public async Task ThreadAbortDuringUnmanagedCall() { object objLock = new object(); ISequencerUC sequencer = SequencerUC .Construct() .Register(Worker.BeforeLock, new StrategyOneOnOneUC()) .Register(Worker.Locked, new StrategyOneOnOneUC()) .Register(Worker.Stuck, new StrategyOneOnOneUC()) ; sequencer.Run(seq => LockedWorker(seq, objLock)); //run 1st thread sequencer.Run(seq => LockedWorker(seq, objLock)); //run 2nd thread sequencer.Run(seq => LockedWorker(seq, objLock)); //run 3rd thread var test1 = await sequencer.TestPointAsync(Worker.BeforeLock); var test2 = await sequencer.TestPointAsync(Worker.BeforeLock); var test3 = await sequencer.TestPointAsync(Worker.BeforeLock); var th1 = test1.ProductionArg as Thread; var th2 = test2.ProductionArg as Thread; var th3 = test3.ProductionArg as Thread; //only one gets inside lock await sequencer.TestPointAsync(Worker.Locked); //and will stuck intentionally var intentionallyStuck = await sequencer.TestPointAsync(Worker.Stuck); await Task.Delay(100); await Task.Delay(100); await Task.Delay(100); await Task.Delay(100); await Task.Delay(100); await Task.Delay(100); try { Thread thread = intentionallyStuck.ProductionArg as Thread; await Task.Delay(100); thread?.Abort(); th1?.Abort(); th2?.Abort(); th3?.Abort(); while (true) { try { await Task.Delay(100); sequencer.TryReThrowException(); } catch (Exception ex) { Assert.Warn(ex.Message); } } } catch (Exception ex) { Assert.Warn(ex.Message); throw; } }
public void Stop() { _statsUpdater?.Abort(); }
private void UI_FormClosing(object sender, FormClosingEventArgs e) { _rendererRunning = false; _renderThread?.Abort(); emu?.Save(); }
private void tstSearch_TextChanged(object sender, EventArgs e) { searchThread?.Abort(); searchThread = new Thread(FilterPlugins); searchThread.Start(tstSearch.Text); }
private void OnDestroy() { _networkThread?.Abort(); }
/// <summary> /// 断开连接 /// </summary> public void DisConnect() { m_Socket?.Close(); m_Socket?.Dispose(); m_ReveiveThread?.Abort(); }
public void Dispose() { _stateThread?.Abort(); _server?.Stop(); }
public void AbortAsync() { workingThread?.Abort(); Status = ParseTaskStatus.Aborted; }
public void Abort() { t?.Abort(); _context?.Dispose(); IsLoaded = false; }
public void Dispose() { HidManager.Dispose(); _updateThread?.Abort(); }
private void OnDestroy() { // Just to be sure kill the thread if this object is destroyed _cpuThread?.Abort(); }
public void Stop() { updateThread?.Abort(); updateThread = null; }