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
19
View Source File : SteamBotController.cs
License : GNU General Public License v3.0
Project Creator : 00000vish
License : GNU General Public License v3.0
Project Creator : 00000vish
public static void logBotOff()
{
steamUser.LogOff();
workThread.Abort();
loggedIn = false;
}
19
View Source File : CelesteNetClientRC.cs
License : MIT License
Project Creator : 0x0ade
License : MIT License
Project Creator : 0x0ade
public static void Shutdown() {
Listener?.Abort();
ListenerThread?.Abort();
Listener = null;
ListenerThread = null;
}
19
View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
License : GNU General Public License v3.0
Project Creator : 0x2b00b1e5
static void OnApplicationExit(object sender, EventArgs e)
{
t.Abort();
}
19
View Source File : DownloadManager.cs
License : MIT License
Project Creator : 404Lcc
License : MIT License
Project Creator : 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
View Source File : SimpleHTTPServer.cs
License : GNU General Public License v3.0
Project Creator : 44670
License : GNU General Public License v3.0
Project Creator : 44670
public void Stop()
{
_serverThread.Abort();
_listener.Stop();
}
19
View Source File : App.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
SecondUIThread?.Abort();
}
19
View Source File : FileHandle.cs
License : MIT License
Project Creator : action-bi-toolkit
License : MIT License
Project Creator : 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
View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : advancedmonitoring
License : MIT License
Project Creator : 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
View Source File : Model.cs
License : MIT License
Project Creator : advancedmonitoring
License : MIT License
Project Creator : 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
View Source File : Model.cs
License : MIT License
Project Creator : advancedmonitoring
License : MIT License
Project Creator : 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
View Source File : ExpirationChecker.cs
License : GNU General Public License v3.0
Project Creator : Aekras1a
License : GNU General Public License v3.0
Project Creator : 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
View Source File : SearchService.cs
License : MIT License
Project Creator : Aeroblast
License : MIT License
Project Creator : 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
View Source File : Shader.cs
License : The Unlicense
Project Creator : aeroson
License : The Unlicense
Project Creator : aeroson
void StopAllWatchers()
{
foreach (var w in watcherThreads)
{
w.Abort();
}
watcherThreads.Clear();
}
19
View Source File : CommunicationManager.cs
License : Apache License 2.0
Project Creator : Aggrathon
License : Apache License 2.0
Project Creator : 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
View Source File : CustomAudioSinkSample.cs
License : MIT License
Project Creator : AgoraIO
License : MIT License
Project Creator : AgoraIO
void OnApplicationQuit()
{
Debug.Log("OnApplicationQuit");
_pullAudioFrameThreadSignal = false;
_pullAudioFrameThread.Abort();
if (mRtcEngine != null)
{
IRtcEngine.Destroy();
}
}
19
View Source File : TCPClientManager.cs
License : MIT License
Project Creator : akihiro0105
License : MIT License
Project Creator : 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
View Source File : UDPSenderManager.cs
License : MIT License
Project Creator : akihiro0105
License : MIT License
Project Creator : 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
View Source File : KrakenX.cs
License : GNU General Public License v3.0
Project Creator : akmadian
License : GNU General Public License v3.0
Project Creator : 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
View Source File : KrakenX.cs
License : GNU General Public License v3.0
Project Creator : akmadian
License : GNU General Public License v3.0
Project Creator : 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
View Source File : KrakenX.cs
License : GNU General Public License v3.0
Project Creator : akmadian
License : GNU General Public License v3.0
Project Creator : 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
View Source File : SoftwareUpdater.cs
License : MIT License
Project Creator : AlbertMN
License : MIT License
Project Creator : 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
View Source File : ThreadItem.cs
License : MIT License
Project Creator : AlenToma
License : MIT License
Project Creator : AlenToma
public void Stop()
{
_thread.Abort();
}
19
View Source File : ArduinoThread.cs
License : GNU General Public License v3.0
Project Creator : AlexandreDoucet
License : GNU General Public License v3.0
Project Creator : AlexandreDoucet
public void Initialisation()
{
if (activeThread != null && activeThread.IsAlive)
{ activeThread.Abort();}
threadQueue.Enqueue((new Thread(AsychronousAutoDetectArduino)));
}
19
View Source File : OnScreenKeyboardWatcher.cs
License : MIT License
Project Creator : AlexeiScherbakov
License : MIT License
Project Creator : AlexeiScherbakov
private void Terminate()
{
_endEvent.Set();
if (!_watcherThread.Join(500))
{
_watcherThread.Abort();
}
}
19
View Source File : PDFExportProgress.cs
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
License : GNU General Public License v3.0
Project Creator : alexgracianoarj
public static void CloseAsync()
{
if(showThread != null && showThread.IsAlive)
{
showThread.Abort();
showThread.Join();
}
}
19
View Source File : HttpServer.cs
License : MIT License
Project Creator : AlexGyver
License : MIT License
Project Creator : 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
View Source File : AbortableThreadPool.cs
License : MIT License
Project Creator : AlexGyver
License : MIT License
Project Creator : 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
View Source File : AbortableThreadPool.cs
License : MIT License
Project Creator : AlexGyver
License : MIT License
Project Creator : AlexGyver
public void CancelAll(bool allowAbort)
{
lock (_callbacks)
{
_callbacks.Clear();
if (allowAbort)
{
foreach (Thread t in _threads.Values)
t.Abort();
}
}
}
19
View Source File : IOUtils.cs
License : MIT License
Project Creator : alexismorin
License : MIT License
Project Creator : alexismorin
public static void Destroy()
{
ActiveThread = false;
if ( SaveInThreadMainThread != null )
{
SaveInThreadMainThread.Abort();
SaveInThreadMainThread = null;
}
}
19
View Source File : TesterServerUi.xaml.cs
License : Apache License 2.0
Project Creator : AlexWan
License : Apache License 2.0
Project Creator : AlexWan
void TesterServerUi_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
barUpdater.Abort();
}
19
View Source File : HTTPChallengeWebServerValidator.cs
License : GNU General Public License v3.0
Project Creator : aloopkin
License : GNU General Public License v3.0
Project Creator : aloopkin
public void EndAllChallengeValidations()
{
_serverThread.Abort();
_listener.Stop();
logger.Debug("Just stopped the HTTP Listener");
}
19
View Source File : MainForm.cs
License : GNU General Public License v2.0
Project Creator : AmanoTooko
License : GNU General Public License v2.0
Project Creator : 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
View Source File : lyricPoster.cs
License : GNU General Public License v2.0
Project Creator : AmanoTooko
License : GNU General Public License v2.0
Project Creator : AmanoTooko
public static void LrcStop()
{
if(LrcThread!=null)
{
LrcThread.Abort();
}
}
19
View Source File : MainForm.cs
License : GNU General Public License v2.0
Project Creator : AmanoTooko
License : GNU General Public License v2.0
Project Creator : 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
View Source File : HotReloader.cs
License : MIT License
Project Creator : AndreiMisiukevich
License : MIT License
Project Creator : AndreiMisiukevich
public void Stop()
{
IsRunning = false;
_daemonThread?.Abort();
_daemonThread = null;
_resourceMapping = null;
}
19
View Source File : DiscordNetModel.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : anoyetta
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 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
View Source File : ThreadWorker.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : anoyetta
License : BSD 3-Clause "New" or "Revised" License
Project Creator : 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
View Source File : SharlayanController.cs
License : MIT License
Project Creator : anoyetta
License : MIT License
Project Creator : 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
View Source File : ThreadWorker.cs
License : MIT License
Project Creator : anoyetta-academy
License : MIT License
Project Creator : 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
View Source File : DiscordBotController.cs
License : MIT License
Project Creator : anoyetta
License : MIT License
Project Creator : 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
View Source File : ChatOverlaysController.cs
License : MIT License
Project Creator : anoyetta
License : MIT License
Project Creator : 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
View Source File : ICU.cs
License : MIT License
Project Creator : aoso3
License : MIT License
Project Creator : 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
View Source File : ICU.cs
License : MIT License
Project Creator : aoso3
License : MIT License
Project Creator : 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
View Source File : ICU.cs
License : MIT License
Project Creator : aoso3
License : MIT License
Project Creator : 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
View Source File : WebSocketSignaling.cs
License : Apache License 2.0
Project Creator : araobp
License : Apache License 2.0
Project Creator : araobp
public void Stop()
{
if (m_running)
{
m_running = false;
m_webSocket?.Close();
m_signalingThread.Abort();
}
}
19
View Source File : MjpegStreamer.cs
License : MIT License
Project Creator : AristotelisChantzaras
License : MIT License
Project Creator : 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
View Source File : OneMiner.cs
License : GNU General Public License v3.0
Project Creator : arunsatyarth
License : GNU General Public License v3.0
Project Creator : 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
View Source File : UnityDebugViewerTransfer.cs
License : Apache License 2.0
Project Creator : AsanCai
License : Apache License 2.0
Project Creator : 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
View Source File : ProxyManager.cs
License : MIT License
Project Creator : Ashesh3
License : MIT License
Project Creator : Ashesh3
public void CancelChecking()
{
lock (ThreadsSync)
{
CheckThreads.RemoveAll(x => x.ThreadState == ThreadState.Unstarted);
foreach (var thread in CheckThreads)
{
thread.Abort();
}
}
}
19
View Source File : FormBackground.cs
License : MIT License
Project Creator : AutoItConsulting
License : MIT License
Project Creator : 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