Here are the examples of the csharp api System.ComponentModel.Component.Dispose() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2779 Examples
19
Source : Watchdog.cs
with MIT License
from 0ffffffffh
with MIT License
from 0ffffffffh
private void KillList(IEnumerable<Process> processes)
{
foreach (var proc in processes)
{
Log.Info("Attempting to kill pid {0}", proc.Id);
try
{
proc.Kill();
}
catch (Exception e)
{
Log.Error(e.Message);
proc.Dispose();
continue;
}
if (!proc.WaitForExit(2000))
{
Log.Error("Pid: {0} cant be killed!", proc.Id);
}
proc.Dispose();
}
}
19
Source : SqlServerIo.cs
with MIT License
from 0ffffffffh
with MIT License
from 0ffffffffh
private void Close()
{
if (conn != null)
{
if (Ready)
conn.Close();
conn.Dispose();
conn = null;
}
}
19
Source : CelesteNetServer.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public void Dispose() {
if (!IsAlive)
return;
Logger.Log(LogLevel.CRI, "main", "Shutdown");
IsAlive = false;
ModulesFSWatcher.Dispose();
lock (Modules) {
foreach (CelesteNetServerModuleWrapper wrapper in ModuleWrappers.ToArray()) {
wrapper.Unload();
}
}
Channels.Dispose();
TCPUDP.Dispose();
ConLock.Dispose();
UserData.Dispose();
Data.Dispose();
}
19
Source : FCheckBox.cs
with MIT License
from 0xLaileb
with MIT License
from 0xLaileb
protected override void OnMouseLeave(EventArgs e)
{
timer_effect_1.Stop();
timer_effect_1.Dispose();
Mouse_Enter = false;
temp = 0;
Refresh();
}
19
Source : FRadioButton.cs
with MIT License
from 0xLaileb
with MIT License
from 0xLaileb
protected override void OnMouseClick(MouseEventArgs e)
{
Checked = !Checked;
timer_effect_1.Stop();
timer_effect_1.Dispose();
if (e.Button == MouseButtons.Left)
{
temp = size_fradiobutton.Width;
if (Checked)
{
timer_effect_1.Tick += (Sender, EventArgs) =>
{
temp += 1;
Refresh();
};
timer_effect_1.Start();
}
else Refresh();
}
}
19
Source : PlatformFileSaveDialog .cs
with GNU General Public License v3.0
from 0xC0000054
with GNU General Public License v3.0
from 0xC0000054
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (vistaFileSaveDialog != null)
{
vistaFileSaveDialog.Dispose();
vistaFileSaveDialog = null;
}
if (clreplacedicFileSaveDialog != null)
{
clreplacedicFileSaveDialog.Dispose();
clreplacedicFileSaveDialog = null;
}
}
base.Dispose(disposing);
}
19
Source : PlatformFolderBrowserDialog.cs
with GNU General Public License v3.0
from 0xC0000054
with GNU General Public License v3.0
from 0xC0000054
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (vistaFolderBrowserDialog != null)
{
vistaFolderBrowserDialog.Dispose();
vistaFolderBrowserDialog = null;
}
if (clreplacedicFolderBrowserDialog != null)
{
clreplacedicFolderBrowserDialog.Dispose();
clreplacedicFolderBrowserDialog = null;
}
}
base.Dispose(disposing);
}
19
Source : FCheckBox.cs
with MIT License
from 0xLaileb
with MIT License
from 0xLaileb
protected override void OnMouseClick(MouseEventArgs e)
{
Checked = !Checked;
timer_effect_1.Stop();
timer_effect_1.Dispose();
if (e.Button == MouseButtons.Left)
{
temp = size_fcheckbox.Width;
if (Checked)
{
timer_effect_1.Tick += (Sender, EventArgs) =>
{
temp += 1;
Refresh();
};
timer_effect_1.Start();
}
else Refresh();
}
}
19
Source : DcWebHook.cs
with MIT License
from 1-EXON
with MIT License
from 1-EXON
public void Dispose()
{
dWebClient.Dispose();
}
19
Source : ServiceStatusManageService.cs
with MIT License
from 1100100
with MIT License
from 1100100
public override async Task StopAsync(CancellationToken cancellationToken)
{
Logger.LogInformation("Stop refreshing service status.");
await base.StopAsync(cancellationToken);
if (Timer == null)
return;
Timer.Enabled = false;
Timer.Dispose();
}
19
Source : FButton.cs
with MIT License
from 0xLaileb
with MIT License
from 0xLaileb
protected override void OnMouseUp(MouseEventArgs e)
{
timer_effect_1.Stop();
timer_effect_1.Dispose();
if (e.Button == MouseButtons.Left && Effect_1 == true)
{
ClickLocation = e.Location;
temp = 2;
timer_effect_1.Tick += (Sender, EventArgs) =>
{
temp += 20;
Refresh();
};
timer_effect_1.Start();
}
}
19
Source : MainForm.cs
with MIT License
from 13xforever
with MIT License
from 13xforever
private void ResetForm()
{
productCodeLabel.Text = "";
gamereplacedleLabel.Text = "";
irdMatchLabel.Text = "";
discSizeLabel.Text = "";
step1StatusLabel.Text = "▶";
step2StatusLabel.Text = "";
step3StatusLabel.Text = "";
step4StatusLabel.Text = "";
step1Label.Text = "Insert PS3 game disc";
step2Label.Text = "Select disc key file";
step3Label.Text = "Decrypt and copy files";
step4Label.Text = "Validate integrity";
step2Label.Enabled = false;
step3Label.Enabled = false;
step4Label.Enabled = false;
currentDumper = null;
discBackgroundWorker?.Dispose();
discBackgroundWorker = new BackgroundWorker { WorkerSupportsCancellation = true, WorkerReportsProgress = true };
discBackgroundWorker.DoWork += DetectPs3DiscGame;
discBackgroundWorker.RunWorkerCompleted += DetectPs3DiscGameFinished;
settingsButton.Enabled = true;
rescanDiscsButton.Enabled = true;
rescanDiscsButton.Visible = true;
selectIrdButton.Visible = false;
selectIrdButton.Enabled = false;
startDumpingButton.Visible = false;
startDumpingButton.Enabled = false;
cancelDiscDumpButton.Visible = false;
cancelDiscDumpButton.Enabled = false;
dumpingProgressLabel.Visible = false;
dumpingProgressLabel.Text = "";
dumpingProgressBar.Visible = false;
dumpingProgressBar.Value = 0;
TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.NoProgress, Handle);
TaskbarManager.Instance.SetProgressValue(0, dumpingProgressBar.Maximum, Handle);
}
19
Source : Net40.cs
with MIT License
from 2881099
with MIT License
from 2881099
public static Task Delay(TimeSpan timeout)
{
var tcs = new TaskCompletionSource<object>();
var timer = new System.Timers.Timer(timeout.TotalMilliseconds) { AutoReset = false };
timer.Elapsed += delegate { timer.Dispose(); tcs.SetResult(null); };
timer.Start();
return tcs.Task;
}
19
Source : MyProgressMonitor.cs
with Apache License 2.0
from 214175590
with Apache License 2.0
from 214175590
public override void end()
{
timer.Stop();
timer.Dispose();
//string note = ("Done in " + elapsed + " seconds!");
transferEnd(id);
}
19
Source : TemplateEngin.cs
with MIT License
from 2881099
with MIT License
from 2881099
public void Dispose() {
_fsw.Dispose();
}
19
Source : PrivoxyHandler.cs
with GNU General Public License v3.0
from 2dust
with GNU General Public License v3.0
from 2dust
public void Stop()
{
if (_process != null)
{
KillProcess(_process);
_process.Dispose();
_process = null;
RunningPort = 0;
}
else
{
Process[] existingPrivoxy = Process.GetProcessesByName(_privoxyName);
foreach (Process p in existingPrivoxy.Where(IsChildProcess))
{
KillProcess(p);
}
}
}
19
Source : V2rayHandler.cs
with GNU General Public License v3.0
from 2dust
with GNU General Public License v3.0
from 2dust
public void V2rayStop()
{
try
{
if (_process != null)
{
KillProcess(_process);
_process.Dispose();
_process = null;
}
else
{
foreach (string vName in lstV2ray)
{
Process[] existing = Process.GetProcessesByName(vName);
foreach (Process p in existing)
{
string path = p.MainModule.FileName;
if (path == $"{Utils.GetPath(vName)}.exe")
{
KillProcess(p);
}
}
}
}
//bool blExist = true;
//if (processId > 0)
//{
// Process p1 = Process.GetProcessById(processId);
// if (p1 != null)
// {
// p1.Kill();
// blExist = false;
// }
//}
//if (blExist)
//{
// foreach (string vName in lstV2ray)
// {
// Process[] killPro = Process.GetProcessesByName(vName);
// foreach (Process p in killPro)
// {
// p.Kill();
// }
// }
//}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
19
Source : dlgSettings.cs
with MIT License
from 86Box
with MIT License
from 86Box
private void btnBrowse3_Click(object sender, EventArgs e)
{
SaveFileDialog ofd = new SaveFileDialog();
ofd.DefaultExt = "log";
ofd.replacedle = "Select a file where 86Box logs will be saved";
ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
ofd.Filter = "Log files (*.log)|*.log";
if (ofd.ShowDialog() == DialogResult.OK)
{
txtLogPath.Text = ofd.FileName;
}
ofd.Dispose();
}
19
Source : FrmMangaBrowser.cs
with GNU General Public License v3.0
from 9vult
with GNU General Public License v3.0
from 9vult
private void FrmMangaBrowser_FormClosing(object sender, FormClosingEventArgs e)
{
browser.Dispose();
}
19
Source : WindowManager.cs
with GNU General Public License v3.0
from a4004
with GNU General Public License v3.0
from a4004
public static void UnmountWindow(Control.ControlCollection parent, Form window)
{
if (window.InvokeRequired)
{
Program.Debug("windowmgr", $"Request to unmount {window.Name} into {parent.Owner.Name} requires control invokation.");
Program.Debug("windowmgr", "Invoking the request on the UI thread.");
window.Invoke(new Action(() => UnmountWindow(parent, window)));
return;
}
foreach (Form w in parent.OfType<Form>().Where(a => a.Handle == window.Handle))
{
Program.Debug("windowmgr", $"Removing window {window.Name} from {parent.Owner.Name}");
parent.Remove(w);
w.Close();
w.Dispose();
}
}
19
Source : TestEngine.cs
with MIT License
from ab4d
with MIT License
from ab4d
public void Dispose()
{
Window.Dispose();
Device.Dispose();
SwapChain.Dispose();
BackBuffer.Dispose();
RenderTargetView.Dispose();
Texture.Dispose();
TextureShaderResourceView.Dispose();
}
19
Source : ProcessResult.cs
with MIT License
from abanu-org
with MIT License
from abanu-org
public void Dispose()
{
try
{
if (Timer != null)
Timer.Stop();
Process?.Dispose();
if (Timer != null)
{
var t = Timer;
Timer = null;
t.Dispose();
}
}
catch (Exception ex)
{
}
finally
{
Process = null;
}
}
19
Source : ShapeFileEnumerator.cs
with Microsoft Public License
from abfo
with Microsoft Public License
from abfo
public void Dispose()
{
_dbReader.Close();
_dbCommand.Dispose();
}
19
Source : ProcessExtensions.cs
with Apache License 2.0
from abist-co-ltd
with Apache License 2.0
from abist-co-ltd
public static async Task<ProcessResult> StartProcessAsync(this Process process, ProcessStartInfo startInfo, bool showDebug = false, CancellationToken cancellationToken = default)
{
Debug.replacedert(!startInfo.UseShellExecute, "Process Start Info must not use shell execution.");
Debug.replacedert(startInfo.RedirectStandardOutput, "Process Start Info must redirect standard output.");
Debug.replacedert(startInfo.RedirectStandardError, "Process Start Info must redirect standard errors.");
process.StartInfo = startInfo;
process.EnableRaisingEvents = true;
var processResult = new TaskCompletionSource<ProcessResult>();
var errorCodeResult = new TaskCompletionSource<string[]>();
var errorList = new List<string>();
var outputCodeResult = new TaskCompletionSource<string[]>();
var outputList = new List<string>();
process.Exited += OnProcessExited;
process.ErrorDataReceived += OnErrorDataReceived;
process.OutputDataReceived += OnOutputDataReceived;
async void OnProcessExited(object sender, EventArgs args)
{
processResult.TrySetResult(new ProcessResult(process.ExitCode, await errorCodeResult.Task, await outputCodeResult.Task));
process.Close();
process.Dispose();
}
void OnErrorDataReceived(object sender, DataReceivedEventArgs args)
{
if (args.Data != null)
{
errorList.Add(args.Data);
if (!showDebug)
{
return;
}
UnityEngine.Debug.LogError(args.Data);
}
else
{
errorCodeResult.TrySetResult(errorList.ToArray());
}
}
void OnOutputDataReceived(object sender, DataReceivedEventArgs args)
{
if (args.Data != null)
{
outputList.Add(args.Data);
if (!showDebug)
{
return;
}
UnityEngine.Debug.Log(args.Data);
}
else
{
outputCodeResult.TrySetResult(outputList.ToArray());
}
}
if (!process.Start())
{
if (showDebug)
{
UnityEngine.Debug.LogError("Failed to start process!");
}
processResult.TrySetResult(new ProcessResult(process.ExitCode, new[] { "Failed to start process!" }, null));
}
else
{
process.BeginOutputReadLine();
process.BeginErrorReadLine();
CancellationWatcher(process);
}
async void CancellationWatcher(Process _process)
{
await Task.Run(() =>
{
try
{
while (!_process.HasExited)
{
if (cancellationToken.IsCancellationRequested)
{
_process.Kill();
}
}
}
catch
{
// ignored
}
});
}
return await processResult.Task;
}
19
Source : FormMain.cs
with MIT License
from Abneed
with MIT License
from Abneed
private void salirToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
this.Dispose();
}
19
Source : NoLockTimer.cs
with MIT License
from ABTSoftware
with MIT License
from ABTSoftware
public void Dispose()
{
_timer?.Dispose();
}
19
Source : RemoveInvalidFeature.cs
with Microsoft Public License
from achimismaili
with Microsoft Public License
from achimismaili
private void btnScopeUnknown_Click(object sender, EventArgs e)
{
string msgString = "All scopes will be checked for this feature. This might take a while. Continue?";
if (MessageBox.Show(msgString, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
this.Hide();
try
{
// search all webs
if (!tryToRemove(featureID, SPFeatureScope.Web))
{
// search all Sites
if (!tryToRemove(featureID, SPFeatureScope.Site))
{
// search all Web Applications
if (!tryToRemove(featureID, SPFeatureScope.WebApplication))
{
// search in Farm Scope
tryToRemove(featureID, SPFeatureScope.Farm);
}
}
}
SPFarm.Local.FeatureDefinitions.Remove(featureID, true);
parentWindow.logTxt(DateTime.Now.ToString(FrmMain.DATETIMEFORMAT) + " - FeatureDefinition was uninstalled." + Environment.NewLine);
this.Close();
this.Dispose();
}
catch
{
parentWindow.logTxt(DateTime.Now.ToString(FrmMain.DATETIMEFORMAT) + " - An error occured iterating through the features ..." + Environment.NewLine);
}
finally
{
this.Close();
this.Dispose();
}
}
}
19
Source : RemoveInvalidFeature.cs
with Microsoft Public License
from achimismaili
with Microsoft Public License
from achimismaili
private void btnScopeCancel_Click(object sender, EventArgs e)
{
string msgString = "Action canceled.";
parentWindow.logTxt(DateTime.Now.ToString(FrmMain.DATETIMEFORMAT) + " - " + msgString + Environment.NewLine);
this.Close();
this.Dispose();
}
19
Source : RemoveInvalidFeature.cs
with Microsoft Public License
from achimismaili
with Microsoft Public License
from achimismaili
private void btnScopeSelected_Click(object sender, EventArgs e)
{
string msgString = string.Empty;
int featurefound = 0;
this.Hide();
try
{
if (radioScopeWeb.Checked)
{
scopeWindowScope = SPFeatureScope.Web;
}
else
{
if (radioScopeSite.Checked)
{
scopeWindowScope = SPFeatureScope.Site;
}
else
{
if (radioScopeWebApp.Checked)
{
scopeWindowScope = SPFeatureScope.WebApplication;
}
else
{
if (radioScopeFarm.Checked)
{
scopeWindowScope = SPFeatureScope.Farm;
}
else
msgString = "Error in scope selection! Task canceled";
MessageBox.Show(msgString);
((FrmMain)parentWindow).logTxt(DateTime.Now.ToString(FrmMain.DATETIMEFORMAT) + " - " + msgString + Environment.NewLine);
return;
}
}
}
featurefound = parentWindow.removeFeaturesWithinFarm(featureID, scopeWindowScope);
if (featurefound == 0)
{
msgString = "Feature not found in Scope:'" + scopeWindowScope.ToString() + "'. Do you want to try something else?";
if (MessageBox.Show(msgString, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
this.Show();
}
else
{
}
}
else
{
msgString = "Success! Feature was found and deactivated " + featurefound + " times in Scope:'" + scopeWindowScope.ToString() + "'!";
MessageBox.Show(msgString);
parentWindow.logTxt(DateTime.Now.ToString(FrmMain.DATETIMEFORMAT) + " - " + msgString + Environment.NewLine);
SPFarm.Local.FeatureDefinitions.Remove(featureID, true);
parentWindow.logTxt(DateTime.Now.ToString(FrmMain.DATETIMEFORMAT) + " - FeatureDefinition was uninstalled." + Environment.NewLine);
}
}
catch
{
}
finally
{
this.Close();
this.Dispose();
}
}
19
Source : RemoveInvalidFeature.cs
with Microsoft Public License
from achimismaili
with Microsoft Public License
from achimismaili
private void btnScopeSelected_Click(object sender, EventArgs e)
{
string msgString = string.Empty;
int featurefound = 0;
this.Hide();
try
{
if (radioScopeWeb.Checked)
{
scopeWindowScope = SPFeatureScope.Web;
}
else
{
if (radioScopeSite.Checked)
{
scopeWindowScope = SPFeatureScope.Site;
}
else
{
if (radioScopeWebApp.Checked)
{
scopeWindowScope = SPFeatureScope.WebApplication;
}
else
{
if (radioScopeFarm.Checked)
{
scopeWindowScope = SPFeatureScope.Farm;
}
else
msgString = "Error in scope selection! Task canceled";
MessageBox.Show(msgString);
((FrmMain)parentWindow).logTxt(DateTime.Now.ToString(FrmMain.DATETIMEFORMAT) + " - " + msgString + Environment.NewLine);
return;
}
}
}
featurefound = parentWindow.RemoveFeaturesWithinFarm(featureID, scopeWindowScope);
if (featurefound == 0)
{
msgString = "Feature not found in Scope:'" + scopeWindowScope.ToString() + "'. Do you want to try something else?";
if (MessageBox.Show(msgString, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
this.Show();
}
else
{
}
}
else
{
msgString = "Success! Feature was found and deactivated " + featurefound + " times in Scope:'" + scopeWindowScope.ToString() + "'!";
MessageBox.Show(msgString);
parentWindow.logTxt(DateTime.Now.ToString(FrmMain.DATETIMEFORMAT) + " - " + msgString + Environment.NewLine);
SPFarm.Local.FeatureDefinitions.Remove(featureID, true);
parentWindow.logTxt(DateTime.Now.ToString(FrmMain.DATETIMEFORMAT) + " - FeatureDefinition was uninstalled." + Environment.NewLine);
}
}
catch
{
}
finally
{
this.Close();
this.Dispose();
}
}
19
Source : RemoveInvalidFeature.cs
with Microsoft Public License
from achimismaili
with Microsoft Public License
from achimismaili
private void btnScopeCancel_Click(object sender, EventArgs e)
{
Log.Information( "Action canceled.");
this.Close();
this.Dispose();
}
19
Source : RemoveInvalidFeature.cs
with Microsoft Public License
from achimismaili
with Microsoft Public License
from achimismaili
private void btnScopeSelected_Click(object sender, EventArgs e)
{
string msgString = string.Empty;
int featurefound = 0;
this.Hide();
try
{
if (radioScopeWeb.Checked)
{
scopeWindowScope = SPFeatureScope.Web;
}
else
{
if (radioScopeSite.Checked)
{
scopeWindowScope = SPFeatureScope.Site;
}
else
{
if (radioScopeWebApp.Checked)
{
scopeWindowScope = SPFeatureScope.WebApplication;
}
else
{
if (radioScopeFarm.Checked)
{
scopeWindowScope = SPFeatureScope.Farm;
}
else
msgString = "Error in scope selection! Task canceled";
MessageBox.Show(msgString);
Log.Information(msgString);
return;
}
}
}
featurefound = parentWindow.RemoveFeaturesWithinFarm(featureID, scopeWindowScope);
if (featurefound == 0)
{
msgString = "Feature not found in Scope:'" + scopeWindowScope.ToString() + "'. Do you want to try something else?";
if (MessageBox.Show(msgString, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
this.Show();
}
}
else
{
msgString = "Success! Feature was found and deactivated " + featurefound + " times in Scope:'" + scopeWindowScope.ToString() + "'!";
MessageBox.Show(msgString);
Log.Information(msgString );
SPFarm.Local.FeatureDefinitions.Remove(featureID, true);
Log.Information("FeatureDefinition was uninstalled.");
}
}
catch
{
}
finally
{
this.Close();
this.Dispose();
}
}
19
Source : RemoveInvalidFeature.cs
with Microsoft Public License
from achimismaili
with Microsoft Public License
from achimismaili
private void btnScopeUnknown_Click(object sender, EventArgs e)
{
string msgString = "All scopes will be checked for this feature. This might take a while. Continue?";
if (MessageBox.Show(msgString, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
{
this.Hide();
try
{
// search all webs
if (!tryToRemove(featureID, SPFeatureScope.Web))
{
// search all Sites
if (!tryToRemove(featureID, SPFeatureScope.Site))
{
// search all Web Applications
if (!tryToRemove(featureID, SPFeatureScope.WebApplication))
{
// search in Farm Scope
tryToRemove(featureID, SPFeatureScope.Farm);
}
}
}
SPFarm.Local.FeatureDefinitions.Remove(featureID, true);
Log.Information("FeatureDefinition was uninstalled.");
this.Close();
this.Dispose();
}
catch (Exception ex)
{
Log.Error("An error occured iterating through the features ..." , ex);
}
finally
{
this.Close();
this.Dispose();
}
}
}
19
Source : ConsoleUtils.cs
with GNU Lesser General Public License v3.0
from acnicholas
with GNU Lesser General Public License v3.0
from acnicholas
[SecurityCritical]
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
internal static void StartHiddenConsoleProg(string exePath, string args, int waitTime)
{
var startInfo = new ProcessStartInfo();
startInfo.FileName = exePath;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
if (!string.IsNullOrEmpty(args))
{
startInfo.Arguments = args;
}
Process p = Process.Start(startInfo);
p.WaitForExit(waitTime);
p.Dispose();
}
19
Source : ProcessInvoker.cs
with MIT License
from actions
with MIT License
from actions
private void Dispose(bool disposing)
{
if (disposing)
{
if (_proc != null)
{
_proc.Dispose();
_proc = null;
}
}
}
19
Source : RunnerService.cs
with MIT License
from actions
with MIT License
from actions
protected override void OnStart(string[] args)
{
RunningLoop = Task.Run(
() =>
{
try
{
bool stopping;
WriteInfo("Starting Actions Runner Service");
TimeSpan timeBetweenRetries = TimeSpan.FromSeconds(5);
lock (ServiceLock)
{
stopping = Stopping;
}
while (!stopping)
{
WriteInfo("Starting Actions Runner listener");
lock (ServiceLock)
{
RunnerListener = CreateRunnerListener();
RunnerListener.OutputDataReceived += RunnerListener_OutputDataReceived;
RunnerListener.ErrorDataReceived += RunnerListener_ErrorDataReceived;
RunnerListener.Start();
RunnerListener.BeginOutputReadLine();
RunnerListener.BeginErrorReadLine();
}
RunnerListener.WaitForExit();
int exitCode = RunnerListener.ExitCode;
// exit code 0 and 1 need stop service
// exit code 2 and 3 need restart runner
switch (exitCode)
{
case 0:
Stopping = true;
WriteInfo(Resource.RunnerExitWithoutError);
break;
case 1:
Stopping = true;
WriteInfo(Resource.RunnerExitWithTerminatedError);
break;
case 2:
WriteInfo(Resource.RunnerExitWithError);
break;
case 3:
WriteInfo(Resource.RunnerUpdateInProcess);
var updateResult = HandleRunnerUpdate();
if (updateResult == RunnerUpdateResult.Succeed)
{
WriteInfo(Resource.RunnerUpdateSucceed);
}
else if (updateResult == RunnerUpdateResult.Failed)
{
WriteInfo(Resource.RunnerUpdateFailed);
Stopping = true;
}
else if (updateResult == RunnerUpdateResult.SucceedNeedRestart)
{
WriteInfo(Resource.RunnerUpdateRestartNeeded);
_restart = true;
ExitCode = int.MaxValue;
Stop();
}
break;
default:
WriteInfo(Resource.RunnerExitWithUndefinedReturnCode);
break;
}
if (Stopping)
{
ExitCode = exitCode;
Stop();
}
else
{
// wait for few seconds before restarting the process
Thread.Sleep(timeBetweenRetries);
}
lock (ServiceLock)
{
RunnerListener.OutputDataReceived -= RunnerListener_OutputDataReceived;
RunnerListener.ErrorDataReceived -= RunnerListener_ErrorDataReceived;
RunnerListener.Dispose();
RunnerListener = null;
stopping = Stopping;
}
}
}
catch (Exception exception)
{
WriteException(exception);
ExitCode = 99;
Stop();
}
});
}
19
Source : VssFileStorage.cs
with MIT License
from actions
with MIT License
from actions
public void Dispose()
{
m_watcher.Dispose();
}
19
Source : SuppressionFileWatcherService.cs
with GNU General Public License v3.0
from Acumatica
with GNU General Public License v3.0
from Acumatica
public void Dispose()
{
if (Interlocked.Exchange(ref _instanceDisposed, INSTANCE_DISPOSED) == INSTANCE_UNDISPOSED)
{
_fileSystemWatcher.Dispose();
}
}
19
Source : UpdateManager.cs
with MIT License
from admaiorastudio
with MIT License
from admaiorastudio
public async Task StopAsync()
{
if (_hubConnection != null)
{
if (_hubConnection.State == HubConnectionState.Connected)
{
await _hubConnection.SendAsync("DisconnectIde", _ideId.ToString());
await Task.Delay(300);
await _hubConnection.StopAsync();
}
}
foreach (var p in new[] { _pServer })
{
if (p is null)
continue;
if (p.HasExited)
continue;
p.Kill();
p.Close();
p.Dispose();
}
_pServer = null;
// Ensure processes are killed
KillRunningProcesses();
}
19
Source : DotnetRunFixture.cs
with MIT License
from AdrianWilczynski
with MIT License
from AdrianWilczynski
public void Dispose()
{
_process.CloseMainWindow();
if (!_process.WaitForExit(TimeSpan.FromSeconds(3).Milliseconds))
{
try { _process.Kill(); } catch { }
}
_process.Dispose();
}
19
Source : ByteBuffer.cs
with GNU General Public License v2.0
from afrantzis
with GNU General Public License v2.0
from afrantzis
private void SetupFSW()
{
// monitor the file for changes
if (fsw != null) {
fsw.Dispose();
fsw = null;
}
fsw = new FileSystemWatcher();
fsw.Path = Path.GetDirectoryName(fileBuf.Filename);
fsw.Filter = Path.GetFileName(fileBuf.Filename);
// Currently we only properly support file content changes
fsw.NotifyFilter = NotifyFilters.LastWrite;
fsw.Changed += new FileSystemEventHandler(OnFileChanged);
fsw.EnableRaisingEvents = true;
}
19
Source : ByteBuffer.cs
with GNU General Public License v2.0
from afrantzis
with GNU General Public License v2.0
from afrantzis
public void CloseFile()
{
lock (LockObj) {
// close the file buffer and dispose the file watcher
if (fileBuf != null && fileOperationsAllowed) {
fileBuf.Close();
fsw.Dispose();
fsw = null;
segCol = null;
// buffer is in an unreadable state...
this.ReadAllowed = false;
}
}
}
19
Source : ConnectionManager.cs
with GNU General Public License v3.0
from affederaffe
with GNU General Public License v3.0
from affederaffe
public void Dispose()
{
_fileSystemWatcher.Changed -= OnFileChanged;
_fileSystemWatcher.Created -= OnFileCreated;
_fileSystemWatcher.Deleted -= OnFileDeleted;
_fileSystemWatcher.Dispose();
_cancellationTokenSource.Cancel();
_cancellationTokenSource.Dispose();
if (_isCinemaInstalled) DisposeCinemaConnection();
if (_isSongCoreInstalled) DisposeSongCoreConnection();
}
19
Source : SqlServerDataBase.cs
with Mozilla Public License 2.0
from agebullhu
with Mozilla Public License 2.0
from agebullhu
public void Close()
{
if (_connection == null)
{
return;
}
try
{
lock (LockData)
{
if (_connection.State == ConnectionState.Open)
{
//Trace.WriteLine("Close Connection", "SqlServerDataBase");
_connection.Close();
}
//Trace.WriteLine(_count--, "Close");
_connection = null;
}
}
catch (Exception exception)
{
_connection?.Dispose();
Trace.WriteLine("Close Error", "SqlServerDataBase");
LogRecorder.Error(exception.ToString());
}
}
19
Source : OperatorContext.cs
with Mozilla Public License 2.0
from agebullhu
with Mozilla Public License 2.0
from agebullhu
public void Dispose()
{
Command.Dispose();
}
19
Source : SqlServerDataBase.cs
with Mozilla Public License 2.0
from agebullhu
with Mozilla Public License 2.0
from agebullhu
private void Close(SqlConnection connection)
{
//int cnt;
lock (Connections)
{
if (!Connections.Remove(connection))
return;
//cnt = Connections.Count;
}
if (connection == null)
{
return;
}
if (connection.State == ConnectionState.Open)
{
try
{
connection.Close();
}
catch (Exception exception)
{
LogRecorderX.Exception(exception);
}
}
try
{
connection.Dispose();
}
catch (Exception exception)
{
LogRecorderX.Exception(exception);
}
}
19
Source : DlnaDeviceAccessor.cs
with MIT License
from aguang-xyz
with MIT License
from aguang-xyz
public void Dispose()
{
_timer.Dispose();
_client.Dispose();
}
19
Source : SsdpClient.cs
with MIT License
from aguang-xyz
with MIT License
from aguang-xyz
public void Dispose()
{
_searchTimer.Dispose();
_checkTimer.Dispose();
_checkUdpClient.Dispose();
}
19
Source : FormAbout.cs
with GNU General Public License v3.0
from AHeroicLlama
with GNU General Public License v3.0
from AHeroicLlama
private void OkButton_Click(object sender, EventArgs e)
{
Close();
Dispose();
}
19
Source : Component.cs
with Mozilla Public License 2.0
from ahyahy
with Mozilla Public License 2.0
from ahyahy
public new void Dispose()
{
M_Component.Dispose();
}
See More Examples