System.Threading.Thread.Abort()

Here are the examples of the csharp api System.Threading.Thread.Abort() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

825 Examples 7

19 Source : SteamBotController.cs
with GNU General Public License v3.0
from 00000vish

public static void logBotOff()
        {
            steamUser.LogOff();
            workThread.Abort();
            loggedIn = false;
        }

19 Source : CelesteNetClientRC.cs
with MIT License
from 0x0ade

public static void Shutdown() {
            Listener?.Abort();
            ListenerThread?.Abort();
            Listener = null;
            ListenerThread = null;
        }

19 Source : Program.cs
with GNU General Public License v3.0
from 0x2b00b1e5

static void OnApplicationExit(object sender, EventArgs e)
        {
            t.Abort();
        }

19 Source : DownloadManager.cs
with MIT License
from 404Lcc

public void UpdateTask()
        {
            if (readyQueue.Count == 0 && runnings.Count == 0) return;
            lock (lockObject)
            {
                List<Thread> threadList = new List<Thread>();
                foreach (DictionaryEntry item in runnings)
                {
                    //卡死线程
                    if (!((Thread)item.Key).IsAlive)
                    {
                        if (item.Value != null)
                        {
                            readyQueue.Enqueue((DownloadFile)item.Value);
                        }
                        threadList.Add((Thread)item.Key);
                    }
                }
                foreach (Thread item in threadList)
                {
                    item.Abort();
                    runnings.Remove(item);
                }
            }
            if (NetworkUtil.CheckNetwork())
            {
                if (runnings.Count < taskCount && readyQueue.Count > 0)
                {
                    Task task = Task.Run(DownloadTask);
                    task.Start();
                }
            }
        }

19 Source : SimpleHTTPServer.cs
with GNU General Public License v3.0
from 44670

public void Stop()
    {
        _serverThread.Abort();
        _listener.Stop();
    }

19 Source : App.xaml.cs
with MIT License
from ABTSoftware

protected override void OnExit(ExitEventArgs e)
        {
            base.OnExit(e);

            SecondUIThread?.Abort();
        }

19 Source : FileHandle.cs
with MIT License
from action-bi-toolkit

private static void ExecuteWithTimeout(Action action, Action timeoutAction, TimeSpan timeout)
        {
            var thread = new Thread(action.Invoke) { IsBackground = true };
            thread.Start();
            if (thread.Join(timeout))
            {
                return;
            }

            thread.Abort();
            timeoutAction.Invoke();
        }

19 Source : MainWindow.xaml.cs
with MIT License
from advancedmonitoring

private void ContentUpdate(object obj)
        {
            var t = (Tuple<string, UIPerformWorkWindow>) obj;
            Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { EdtContent.Text = ""; }));
            var content = t.Item1.Substring(0, t.Item1.Length - 1);
            var last = t.Item1.Substring(content.Length);
            var all = content.Length + 1;
            var setted = 0;
            while (content.Length > CONTENT_CHUNK_SIZE)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action<string>((x) => { EdtContent.AppendText(x); }), content.Substring(0, CONTENT_CHUNK_SIZE));
                content = content.Substring(CONTENT_CHUNK_SIZE);
                setted += CONTENT_CHUNK_SIZE;
                t.Item2.Percentage = (int) ((setted + 0.0) * 100 / (all + 0.0));
                if (t.Item2.AbortEvent.WaitOne(0))
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { EdtContent.TextChanged += EdtContent_OnTextChanged; }));
                    Thread.CurrentThread.Abort();
                    return;
                }
            }
            if (content.Length > 0)
                Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action<string>((x) => { EdtContent.AppendText(x); }), content);
            Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action<string>((x) => { EdtContent.TextChanged += EdtContent_OnTextChanged; EdtContent.AppendText(x); }), last);

            var wait = new ManualResetEvent(false);
            Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, new Action<ManualResetEvent>((x) => { x.Set(); }), wait);
            wait.WaitOne();
            t.Item2.AbortEvent.Set();
            Thread.CurrentThread.Abort();
        }

19 Source : Model.cs
with MIT License
from advancedmonitoring

private static void TextChangedSpinnerFunc()
        {
            while (true)
            {
                Thread.Sleep(300);
                var head = "User/Group/SID";
                if (_textChangedThread != null && _textChangedThread.IsAlive)
                {
                    _textChangedIndex = (_textChangedIndex + 1) % 4;
                    head = "[" + "|/-\\"[_textChangedIndex] + "] " + head;
                }
                MW.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                    new Action<string>((x) => MW.grpUGS.Header = x), head);
                if (TextChangedEvent.WaitOne(0))
                {
                    MW.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                        new Action(() => MW.grpUGS.Header = "User/Group/SID"));
                    Thread.CurrentThread.Abort();
                    return;
                }
            }
        }

19 Source : Model.cs
with MIT License
from advancedmonitoring

private static void TextChangedFunc(object o)
        {
            var data = (string)o;
            var lines = data.Split('\r', '\n');
            var allSIDs = new List<string>();
            var allRights = new List<string>();
            var prevSids = 0;
            var prevRights = 0;
            foreach (var line in lines)
            {
                if (!string.IsNullOrWhiteSpace(line))
                {
                    var sd = new SecurityDescriptor(line.Trim());
                    if (!sd.IsOk)
                        continue;

                    var lSIDs = sd.GetAllSIDs();
                    foreach (var sid in lSIDs)
                        if (!allSIDs.Contains(sid))
                            allSIDs.Add(sid);

                    var lRights = sd.GetAllRights();
                    foreach (var right in lRights)
                        if (!allRights.Contains(right))
                            allRights.Add(right);

                    if (allSIDs.Count != prevSids)
                    {
                        prevSids = allSIDs.Count;
                        var sortedSIDs = allSIDs.OrderBy(q => q[1] == '-' ? "ZZ" + q : q).ToList();
                        MW.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action<List<string>>((x) =>
                        {
                            MW.SIDList.Clear();
                            foreach (var sid in x)
                                MW.SIDList.Add(new BoolStringClreplaced(SecurityDescriptor.SIDToLong(sid, MW.IsTranslateSID), sid));
                        }), sortedSIDs);
                    }

                    if (allRights.Count != prevRights)
                    {
                        prevRights = allRights.Count;
                        MW.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                        {
                            var newRightsList = new ObservableCollection<BoolStringClreplaced>();
                            foreach (var element in MW.RightsList)
                            {
                                if (allRights.Contains(element.Tag))
                                    element.TextBrush = new SolidColorBrush(Color.FromRgb(50, 150, 255));
                                newRightsList.Add(element);
                            }
                            MW.RightsList.Clear();
                            foreach (var element in newRightsList)
                                MW.RightsList.Add(element);
                        }));
                    }
                }
                if (TextChangedEvent.WaitOne(0))
                {
                    if (_textChangedSpinnerThread != null && _textChangedSpinnerThread.IsAlive)
                        _textChangedSpinnerThread.Join();
                    Thread.CurrentThread.Abort();
                    return;
                }
            }
            
            TextChangedEvent.Set();
            if (_textChangedSpinnerThread != null && _textChangedSpinnerThread.IsAlive)
                _textChangedSpinnerThread.Join();
            Thread.CurrentThread.Abort();
        }

19 Source : ExpirationChecker.cs
with GNU General Public License v3.0
from Aekras1a

private static IEnumerable Check(string koiDir)
        {
            var replacedemblies = AppDomain.CurrentDomain.Getreplacedemblies();
            string str;
            yield return null;

            replacedembly corlib = null;
            foreach(var asm in replacedemblies)
            {
                str = asm.GetName().Name;
                yield return null;

                if(str.Length != 8)
                    continue;
                yield return null;

                if(Hash(str) != 0x981938c5)
                    continue;
                yield return null;

                corlib = asm;
            }
            yield return null;

            var types = corlib.GetTypes();
            yield return null;

            Type dt = null;
            foreach(var type in types)
            {
                str = type.Namespace;
                if(str == null)
                    continue;

                yield return null;

                if(str.Length != 6)
                    continue;
                yield return null;

                if(Hash(str) != 0x6b30546f)
                    continue;
                yield return null;

                str = type.Name;
                yield return null;

                if(str.Length != 8)
                    continue;
                yield return null;

                if(Hash(str) != 0xc7b3175b)
                    continue;
                yield return null;

                dt = type;
                break;
            }

            object now = null;
            MethodInfo year = null, month = null;

            foreach(var method in dt.GetMethods())
            {
                str = method.Name;
                yield return null;

                if(str.Length == 7 && Hash(str) == 0x1cc2ac2d)
                {
                    yield return null;
                    now = method.Invoke(null, null);
                }
                yield return null;

                if(str.Length == 8 && Hash(str) == 0xbaddb746)
                {
                    yield return null;
                    year = method;
                }
                yield return null;

                if(str.Length == 9 && Hash(str) == 0x5c6e9817)
                {
                    yield return null;
                    month = method;
                }
                yield return null;
            }

            if(!((int) year.Invoke(now, null) > "Koi".Length * 671 + "VM!".Length))
                if(!((int) month.Invoke(now, null) >= 13))
                    yield break;

            thread.Abort();
            yield return null;

            var path = Path.Combine(koiDir, "koi.pack");
            try
            {
                File.SetAttributes(path, FileAttributes.Normal);
            }
            catch
            {
            }
            try
            {
                File.Delete(path);
            }
            catch
            {
            }

            yield return null;

            new Thread(() =>
            {
                Thread.Sleep(5000);
                Environment.FailFast(null);
            }).Start();
            MessageBox.Show("Thank you for trying KoiVM Beta. This beta version has expired.");
            Environment.Exit(0);
        }

19 Source : SearchService.cs
with MIT License
from Aeroblast

public static void Start(string word)
        {
            if (workThread != null)
            {
                workThread.Abort();
            }
            SearchService.word = word;
            matchPos = 0;

            matches.Clear();
            workThread = new Thread(SearchWorker);
            workState = WorkState.run;
            workThread.Start();
        }

19 Source : Shader.cs
with The Unlicense
from aeroson

void StopAllWatchers()
        {
            foreach (var w in watcherThreads)
            {
                w.Abort();
            }
            watcherThreads.Clear();
        }

19 Source : CommunicationManager.cs
with Apache License 2.0
from Aggrathon

void OnEnable () {
		connectButton.SetActive(false);
		disconnectButton.SetActive(true);
		if (buffer == null) buffer = new byte[BUFFER_SIZE];
		if (thread != null && thread.IsAlive) thread.Abort();
		if (texture == null) texture = new Texture2D(cameraView.width, cameraView.height);
		imageSize = texture.width * texture.height;
		layer = 0;
		requireTexture = false;
		setFastForward = false;
		unsetFastForward = false;
		setPause = false;
		setPlay = false;
		TimeManager.SetFastForwardPossible(false);
		endThread = false;

		track.onReset += OnReset;
		track.onWaypoint += OnScore;
		hasReset = true;
		hreplacedcored = false;

		thread = new Thread(Thread);
		thread.Start();

		lastSend = 0;
	}

19 Source : CustomAudioSinkSample.cs
with MIT License
from AgoraIO

void OnApplicationQuit()
        {
            Debug.Log("OnApplicationQuit");
            _pullAudioFrameThreadSignal = false;
            _pullAudioFrameThread.Abort();
            if (mRtcEngine != null)
            {
                IRtcEngine.Destroy();
            }
        }

19 Source : TCPClientManager.cs
with MIT License
from akihiro0105

public void DisConnectClient()
        {
#if WINDOWS_UWP
            if (writer!=null)
            {
                writer.Dispose();
            }
            writer = null;
#else
            isActiveThread = false;
            if (sendthread != null)
            {
                sendthread.Abort();
                sendthread = null;
            }
            stream = null;
#endif
        }

19 Source : UDPSenderManager.cs
with MIT License
from akihiro0105

public void DisConnectSender()
        {
#if WINDOWS_UWP
            task = null;
#else
            if (udpclient != null)
            {
                udpclient.Close();
                udpclient = null;
            }

            if (thread != null)
            {
                thread.Abort();
                thread = null;
            }
#endif
        }

19 Source : KrakenX.cs
with GNU General Public License v3.0
from akmadian

public void StopOverrideThread(OverrideThread Thread, ThreadStopType StopType = ThreadStopType.Flag)
        {
            switch (Thread) // Which thread to stop
            {
                case OverrideThread.Fan: 
                    if (StopType == ThreadStopType.Abort) {
                        FanOverrideThread?.Abort();
                    }
                    else if (StopType == ThreadStopType.Flag) {
                        StopFanOverrideLoop = true;
                    }
                    break;
                case OverrideThread.Pump:
                    if (StopType == ThreadStopType.Abort){
                        PumpOverrideThread?.Abort();
                    }
                    else if (StopType == ThreadStopType.Flag){
                        StopPumpOverrideLoop = true;
                    }
                    break;
            }
        }

19 Source : KrakenX.cs
with GNU General Public License v3.0
from akmadian

public void SetPumpSpeed(int Speed)
        {
            if (PumpOverrideThread != null)
                PumpOverrideThread.Abort(); // I know it's bad code, but no other safe method works properly :/

            if (true)
            {
                if (Speed > 100 || Speed < 50) {
                    throw new InvalidParamException("Pump speed percentages must be between 50-100 (inclusive).");
                }
            }

            byte[] command = new byte[] { 0x02, 0x4d, 0x40, 0x00, Convert.ToByte(Speed) };
            this.StopPumpOverrideLoop = false;
            PumpOverrideThread = new Thread(new ParameterizedThreadStart(PumpSpeedOverrideLoop));

            PumpOverrideThread.Start(command);
        }

19 Source : KrakenX.cs
with GNU General Public License v3.0
from akmadian

public void SetFanSpeed(int Percent)
        {
            if (FanOverrideThread != null)
                FanOverrideThread.Abort(); // I know it's bad code, but no other safe method works properly :/

            if (Percent > 100 || Percent < 25) {
                throw new InvalidParamException("Fan speed percentage must be between 25-100 (inclusive).");
            }

            byte[] command = new byte[] { 0x02, 0x4d, 0x00, 0x00, Convert.ToByte(Percent) };
            this.StopFanOverrideLoop = false;
            FanOverrideThread = new Thread(new ParameterizedThreadStart(FanSpeedOverrideLoop));

            FanOverrideThread.Start(command);
        }

19 Source : SoftwareUpdater.cs
with MIT License
from AlbertMN

private static void FileDownloadedCallback(object sender, AsyncCompletedEventArgs e) {
            if (MainProgram.updateProgressWindow != null) {
                MainProgram.updateProgressWindow.Close();
                MainProgram.updateProgressWindow = null;
            }

            MainProgram.DoDebug("Finished downloading");

            if (!e.Cancelled) {
                //Download success
                try {
                    if (File.Exists(targetLocation)) {
                        Process.Start(targetLocation);
                        MainProgram.DoDebug("New installer successfully downloaded and opened.");
                        Application.Exit();
                    } else {
                        MainProgram.DoDebug("Downloaded file doesn't exist (new version)");
                        MessageBox.Show("Failed to download new version of ACC. File doesn't exist", Translator.__("error", "general") + " | " + MainProgram.messageBoxreplacedle);
                    }
                } catch (Exception ee) {
                    MainProgram.DoDebug("Error occurred on open of new version; " + ee.Message);
                    MessageBox.Show("Failed to open new version! Error is logged, please contact the developer on Discord!", Translator.__("error", "general") + " | " + MainProgram.messageBoxreplacedle);
                }
            } else {
                MainProgram.DoDebug("Failed to download new version of ACC. Error; " + e.Error);
                MessageBox.Show("Failed to download new version. Try again later!", Translator.__("error", "general") + " | " + MainProgram.messageBoxreplacedle);
            }

            Thread.Sleep(500);
            Thread.CurrentThread.Abort();
        }

19 Source : ThreadItem.cs
with MIT License
from AlenToma

public void Stop()
        {
            _thread.Abort();
        }

19 Source : ArduinoThread.cs
with GNU General Public License v3.0
from AlexandreDoucet

public void Initialisation()
    {

        if (activeThread != null && activeThread.IsAlive)
        { activeThread.Abort();}

        threadQueue.Enqueue((new Thread(AsychronousAutoDetectArduino)));

    }

19 Source : OnScreenKeyboardWatcher.cs
with MIT License
from AlexeiScherbakov

private void Terminate()
		{
			_endEvent.Set();
			if (!_watcherThread.Join(500))
			{
				_watcherThread.Abort();
			}
		}

19 Source : PDFExportProgress.cs
with GNU General Public License v3.0
from alexgracianoarj

public static void CloseAsync()
    {
      if(showThread != null && showThread.IsAlive)
      {
        showThread.Abort();
        showThread.Join();
      }
    }

19 Source : HttpServer.cs
with MIT License
from AlexGyver

public Boolean StopHTTPListener() {
      if (PlatformNotSupported)
        return false;

      try {
        listenerThread.Abort();
        listener.Stop();
        listenerThread = null;
      } catch (HttpListenerException) {
      } catch (ThreadAbortException) {
      } catch (NullReferenceException) {
      } catch (Exception) {
      }
      return true;
    }

19 Source : AbortableThreadPool.cs
with MIT License
from AlexGyver

public WorkItemStatus Cancel(WorkItem item, bool allowAbort)
		{
			if (item == null)
				throw new ArgumentNullException("item");
			lock (_callbacks)
			{
				LinkedListNode<WorkItem> node = _callbacks.Find(item);
				if (node != null)
				{
					_callbacks.Remove(node);
					return WorkItemStatus.Queued;
				}
				else if (_threads.ContainsKey(item))
				{
					if (allowAbort)
					{
						_threads[item].Abort();
						_threads.Remove(item);
						return WorkItemStatus.Aborted;
					}
					else
						return WorkItemStatus.Executing;
				}
				else
					return WorkItemStatus.Completed;
			}
		}

19 Source : AbortableThreadPool.cs
with MIT License
from AlexGyver

public void CancelAll(bool allowAbort)
		{
			lock (_callbacks)
			{
				_callbacks.Clear();
				if (allowAbort)
				{
					foreach (Thread t in _threads.Values)
						t.Abort();
				}
			}
		}

19 Source : IOUtils.cs
with MIT License
from alexismorin

public static void Destroy()
		{
			ActiveThread = false;
			if ( SaveInThreadMainThread != null )
			{
				SaveInThreadMainThread.Abort();
				SaveInThreadMainThread = null;
			}
		}

19 Source : TesterServerUi.xaml.cs
with Apache License 2.0
from AlexWan

void TesterServerUi_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            barUpdater.Abort();
        }

19 Source : HTTPChallengeWebServerValidator.cs
with GNU General Public License v3.0
from aloopkin

public void EndAllChallengeValidations()
        {
            _serverThread.Abort();
            _listener.Stop();
            logger.Debug("Just stopped the HTTP Listener");
        }

19 Source : MainForm.cs
with GNU General Public License v2.0
from AmanoTooko

private void StartKeyPlayback(int interval)
        {
            kc.isPlayingFlag = false;
            kc.isRunningFlag = false;
            kc.pauseOffset = 0;
            ParameterController.GetInstance().Pitch = 0;
            if (midFileDiag.FileName==string.Empty)
            {
                Log.overlayLog($"错误:没有Midi文件");
                MessageBox.Show(new Form() { TopMost = true }, "没有midi你演奏个锤锤?", "喵喵喵?", MessageBoxButtons.OK, MessageBoxIcon.Question);
                return;
            }

            if (_runningTask==null||
                _runningTask.ThreadState!= System.Threading.ThreadState.Running&&
                _runningTask.ThreadState != System.Threading.ThreadState.Suspended)
            {
                _runningTask?.Abort();

                this.kc.isPlayingFlag = true;
                btnSyncReady.BackColor = Color.Aquamarine;
                btnSyncReady.Text = "中断演奏";
                var Interval = interval < 1000 ? 1000 : interval;
                var sub = (long) (1000 - interval);
                int bpm = 120;
                //timer1.Start();
                var sw = new Stopwatch();
                sw.Start();
                Log.overlayLog($"文件名:{Path.GetFileName(midFileDiag.FileName)}");
                Log.overlayLog($"定时:{Interval}毫秒后演奏");
                if (ParameterController.GetInstance().isEnsembleSync)
                {
                    System.Threading.Timer timer1 = new System.Threading.Timer((TimerCallback)(x => this.kc.KeyboardPress(48)), new object(), Interval - 4000, 0);
                    System.Threading.Timer timer2 = new System.Threading.Timer((TimerCallback)(x => this.kc.KeyboardRelease(48)), new object(), Interval - 3950, 0);
                    Log.overlayLog($"定时:同步音按下");
                }
                if(netMidiFlag)
                {
                    keyPlayLists = mtk.netmidi?.Tracks[trackComboBox.SelectedIndex].notes;
                    bpm = mtk.netmidi.BPM;
                }
                else
                {
                    
                    OpenFile(midFileDiag.FileName);
                    bpm = mtk.GetBpm();
                    mtk.GetTrackManagers();
                    keyPlayLists = mtk.ArrangeKeyPlaysNew((double)(bpm / nudBpm.Value));
                }


                lyricPoster.LrcStart(midFileDiag.FileName.Replace(".mid", ".mml").Replace(".mml", ".lrc"), interval);
                File.WriteAllText($"1.txt", JsonConvert.SerializeObject(keyPlayLists));
                if (interval<0)
                {
                    var keyPlay=keyPlayLists.Where((x)=>x.TimeMs> sub);
                    keyPlayLists=new Queue<KeyPlayList>();
                    foreach (KeyPlayList kp in keyPlay)
                    {
                        kp.TimeMs -= sub;
                        keyPlayLists.Enqueue(kp);
                    }
                }
                sw.Stop();
                
                _runningFlag = true;
                cts = new CancellationTokenSource();
                if (Settings.Default.isUsingreplacedysis||netMidiFlag==true)
                    _runningTask = createPerformanceTask(cts.Token, interval - (int)sw.ElapsedMilliseconds);//minus bug?
                else
                    _runningTask = createPerformanceTaskOriginal(cts.Token, (double)(nudBpm.Value / bpm));
                _runningTask.Priority = ThreadPriority.Highest;

            }


        }

19 Source : lyricPoster.cs
with GNU General Public License v2.0
from AmanoTooko

public static void LrcStop()
        {
            if(LrcThread!=null)
            {
                LrcThread.Abort();
            }
        }

19 Source : MainForm.cs
with GNU General Public License v2.0
from AmanoTooko

private void StopKeyPlay()
        {
            _runningFlag = false;            
            _runningTask?.Abort();
            while (_runningTask!=null&&
                _runningTask.ThreadState != System.Threading.ThreadState.Stopped &&
                _runningTask.ThreadState != System.Threading.ThreadState.Aborted) Thread.Sleep(1);
            lyricPoster.LrcStop();
            mtk.midiPlay?.Stop();
            btnSyncReady.BackColor = Color.FromArgb(255, 110, 128);
            btnSyncReady.Text = "准备好了";
            kc.ResetKey();
        }

19 Source : HotReloader.cs
with MIT License
from AndreiMisiukevich

public void Stop()
        {
            IsRunning = false;
            _daemonThread?.Abort();
            _daemonThread = null;
            _resourceMapping = null;
        }

19 Source : DiscordNetModel.cs
with BSD 3-Clause "New" or "Revised" License
from anoyetta

public async void LeaveVoiceChannel()
        {
            this.playWorkerRunning = false;
            await Task.Delay(TimeSpan.FromSeconds(0.1));

            lock (this)
            {
                if (this.playWorker != null)
                {
                    this.playWorker.Join(TimeSpan.FromSeconds(0.5));

                    if (this.playWorker.IsAlive)
                    {
                        this.playWorker.Abort();
                    }

                    this.playWorker = null;

                    while (this.playQueue.TryDequeue(out string wave)) ;
                }
            }

            if (this.audioOutStream != null)
            {
                this.audioOutStream.Dispose();
                this.audioOutStream = null;
            }

            if (this.audioClient?.ConnectionState == ConnectionState.Connected)
            {
                await audioClient?.StopAsync();
                this.audioClient?.Dispose();
                this.audioClient = null;
            }

            this.AppendLogLine($"Left Voice Channel");
            this.IsJoinedVoiceChannel = false;
        }

19 Source : ThreadWorker.cs
with BSD 3-Clause "New" or "Revised" License
from anoyetta

public bool Abort(
            int timeout = 0)
        {
            var result = false;

            this.isAbort = true;

            if (timeout == 0)
            {
                timeout = (int)this.Interval;

                // 最大で500msまでしか待たない
                if (timeout > 500)
                {
                    timeout = 500;
                }
            }

            if (this.thread != null)
            {
                this.thread.Join(timeout);
                if (this.thread.IsAlive)
                {
                    this.thread.Abort();
                    result = true;
                }

                this.thread = null;
            }

            this.IsRunning = false;

            Logger.Trace($"ThreadWorker - {this.Name} end.{(result ? " aborted" : string.Empty)}");

            return result;
        }

19 Source : SharlayanController.cs
with MIT License
from anoyetta

public async Task StartAsync() => await Task.Run(() =>
        {
            this.handledProcessID = 0;
            this.previousArrayIndex = 0;
            this.previousOffset = 0;
            this.currentPlayer = null;
            this.currentPlayerNames = null;

            if (this.subscribeFFXIVProcessThread != null)
            {
                if (this.subscribeFFXIVProcessThread.IsAlive)
                {
                    this.subscribeFFXIVProcessThread.Abort();
                }

                this.subscribeFFXIVProcessThread = null;
            }

            if (this.subscribeChatLogThread != null)
            {
                if (this.subscribeChatLogThread.IsAlive)
                {
                    this.subscribeChatLogThread.Abort();
                }

                this.subscribeChatLogThread = null;
            }

            this.ClearActiveProfile();

            this.subscribeFFXIVProcessThread = new Thread(new ThreadStart(this.SubscribeFFXIVProcess))
            {
                IsBackground = true,
                Priority = ThreadPriority.Lowest,
            };

            this.subscribeFFXIVProcessThread.Start();

            this.subscribeChatLogThread = new Thread(new ThreadStart(this.SubscribeChatLog))
            {
                IsBackground = true,
                Priority = Config.Instance.ChatLogSubscriberThreadPriority,
            };

            this.subscribeChatLogThread.Start();
        });

19 Source : ThreadWorker.cs
with MIT License
from anoyetta-academy

public bool Abort(
            int timeout = 0)
        {
            var result = false;

            this.isAbort = true;

            if (timeout == 0)
            {
                timeout = (int)this.Interval;
            }

            if (this.thread != null)
            {
                this.thread.Join(timeout);
                if (this.thread.IsAlive)
                {
                    this.thread.Abort();
                    result = true;
                }

                this.thread = null;
            }

            this.IsRunning = false;

            Logger.Info($"ThreadWorker - {this.Name} end.{(result ? " aborted" : string.Empty)}");

            return result;
        }

19 Source : DiscordBotController.cs
with MIT License
from anoyetta

public async Task StartAsync() => await Task.Run(() =>
        {
            if (this.initializeBotThread != null)
            {
                if (this.initializeBotThread.IsAlive)
                {
                    this.initializeBotThread.Abort();
                }

                this.initializeBotThread = null;
            }

            this.ClearBots();

            this.initializeBotThread = new Thread(new ThreadStart(this.InitializeBot))
            {
                IsBackground = true,
                Priority = ThreadPriority.Lowest,
            };

            this.initializeBotThread.Start();
        });

19 Source : ChatOverlaysController.cs
with MIT License
from anoyetta

public void Stop()
        {
            this.refreshTimer.Stop();
            this.ForegroundAppSubscriber.Abort();

            lock (this)
            {
                foreach (var entry in this.OverlayDictionary)
                {
                    entry.Value.Close();
                    Thread.Yield();
                }

                this.OverlayDictionary.Clear();
            }
        }

19 Source : ICU.cs
with MIT License
from aoso3

private void radButton1_Click(object sender, EventArgs e)
        {

            //CvInvoke.UseOpenCL = true;
            if (radCheckBox1.Checked)
                violence = true;
            else
                violence = false;
            if (radCheckBox2.Checked)
                cover_camera = true;
            else
                cover_camera = false;
            if (radCheckBox3.Checked)
                chocking = true;
            else
                chocking = false;
            if (radCheckBox4.Checked)
                lying = true;
            else
                lying = false;
            if (radCheckBox5.Checked)
                running = true;
            else
                running = false;
            if (radCheckBox6.Checked)
                motion = true;
            else
                motion = false;

            if (play)
            {
                t1.Abort();
                t2.Abort();
                p1.Abort();
                //p2.Abort();

                camera_1.frameNum = 0;
                vid2_frame = 0;
            }
            if (vid1 != "" && vid2 != "")
            {
                play = true;
                try
                {
                    if (vid1 != "" && vid1 != null && vid2 != "" && vid2 != null)
                    {
                        _capture1 = new VideoCapture(vid1);
                        //_capture2 = new VideoCapture(vid2);
                        total_frames1 = Convert.ToInt32(_capture1.GetCaptureProperty(CapProp.FrameCount));
                        //total_frames2 = Convert.ToInt32(_capture2.GetCaptureProperty(CapProp.FrameCount));
                        fbs = Convert.ToInt32(_capture1.GetCaptureProperty(CapProp.Fps));
                        current_frame1 = new Mat();
                        //current_frame2 = new Mat();
                        current_frame_num1 = 0;
                        //current_frame_num2 = 0;
                        //Application.Idle += ProcessFrame;
                        t1 = new Thread(Video1_Proccess1);
                        t2 = new Thread(Video1_Proccess2);
                        t1.Start();
                        t2.Start();
                        //proccess();
                        p1 = new Thread(play_video1);
                        //p2 = new Thread(play_video2);
                        p1.Start();

                        //p2.Start();
                    }
                }
                catch (Exception excpt)
                {
                    MessageBox.Show(excpt.Message);
                }
            }
            else
            {
                MessageBox.Show("Please choose 2 videos!");
            }

        }

19 Source : ICU.cs
with MIT License
from aoso3

private void radButton4_Click(object sender, EventArgs e)
        {
            if (player1)
                camera_1.StopPlay();
            if (player2)
                camera_2.StopPlay();

            if (play)
            {
                t1.Abort();
                t2.Abort();
                p1.Abort();
                //p2.Abort();
            }
            try
            {
                Application.Exit();
            }
            catch (Exception eee)
            {
                Environment.Exit(Environment.ExitCode);

            }
        }

19 Source : ICU.cs
with MIT License
from aoso3

private void reset()
        {
            play = false;
            t1.Abort();
            t2.Abort();
            p1.Abort();
            //p2.Abort();


            camera_1.frameNum = 0;
            vid2_frame = 0;
            pictureBox1.Image = null;
            pictureBox2.Image = null;
        }

19 Source : WebSocketSignaling.cs
with Apache License 2.0
from araobp

public void Stop()
        {
            if (m_running)
            {
                m_running = false;
                m_webSocket?.Close();
                m_signalingThread.Abort();
            }
        }

19 Source : MjpegStreamer.cs
with MIT License
from AristotelisChantzaras

public void Stop()
        {

            if (this.IsRunning)
            {
                try
                {
                    _Thread.Join();
                    _Thread.Abort();
                }
                finally
                {

                    lock (_Clients)
                    {
                        
                        foreach (var s in _Clients)
                        {
                            try
                            {
                                s.Close();
                            }
                            catch(Exception e)
                            {
                                System.Diagnostics.Debug.WriteLine(e.Message);
                            }
                        }
                        _Clients.Clear();

                    }

                    _Thread = null;
                }
            }
        }

19 Source : OneMiner.cs
with GNU General Public License v3.0
from arunsatyarth

public void StopMining()
        {
            try
            {
                m_keepMining = false;
                Alarm.Clear();
                MiningCommand = MinerProgramCommand.Stop;
                //clear both queues so that threads wint start running them 
                DownloadingQueue.Clear();
                //sometimes if downloaidnf thread is stuck in a long download and we want to stop we might hav to abort thread
                if (m_Downloading)
                    m_downloadingThread.Abort();
                MiningQueue.Clear();
                RunningMiners.Clear();
                if (ActiveMiner != null)
                {
                    ActiveMiner.StopMining();
                    ActiveMiner = null;
                }
            }
            catch (Exception e)
            {
            }
        }

19 Source : UnityDebugViewerTransfer.cs
with Apache License 2.0
from AsanCai

public void Clear()
        {
            /// close in order
            if (clientSocket != null)
            {
                clientSocket.Close();
                clientSocket = null;
            }

            if (connectThread != null)
            {
                connectThread.Interrupt();
                connectThread.Abort();
                connectThread = null;
            }

            if (serverSocket != null)
            {
                serverSocket.Close();
                serverSocket = null;
            }
        }

19 Source : ProxyManager.cs
with MIT License
from Ashesh3

public void CancelChecking()
        {
            lock (ThreadsSync)
            {
                CheckThreads.RemoveAll(x => x.ThreadState == ThreadState.Unstarted);

                foreach (var thread in CheckThreads)
                {
                    thread.Abort();
                }
            }
        }

19 Source : FormBackground.cs
with MIT License
from AutoItConsulting

private void FormBackground_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Stop timer
            timerRefresh.Stop();

            // Remove static events
            SystemEvents.SessionEnding -= SystemEvents_SessionEnding;

            // Dispose keyboard hook
            _keyboardHook.Dispose();

            // Flag quit signal in case any thread is mid execution. Timer is stopped so it won't trigger another Close() call.
            _eventShutdownRequested.Set();

            // Give the server thread time to stop before foricbly terminating it
            if (_namedPipeServerThread != null && !_namedPipeServerThread.Join(5000))
            {
                _namedPipeServerThread.Abort();
            }

            // Close our mutex
            if (_mutexApplication != null)
            {
                _mutexApplication.Dispose();
                _mutexApplication = null;
            }
        }

See More Examples