System.ComponentModel.Component.Dispose()

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 7

19 View Source File : UpdateManager.cs
License : MIT License
Project Creator : 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 View Source File : DlnaDeviceAccessor.cs
License : MIT License
Project Creator : aguang-xyz

public void Dispose()
        {
            _timer.Dispose();
            _client.Dispose();
        }

19 View Source File : ShapeFileEnumerator.cs
License : Microsoft Public License
Project Creator : abfo

public void Dispose()
        {
            _dbReader.Close();
            _dbCommand.Dispose();
        }

19 View Source File : ProcessInvoker.cs
License : MIT License
Project Creator : actions

private void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_proc != null)
                {
                    _proc.Dispose();
                    _proc = null;
                }
            }
        }

19 View Source File : RemoveInvalidFeature.cs
License : Microsoft Public License
Project Creator : 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 View Source File : FrmMangaBrowser.cs
License : GNU General Public License v3.0
Project Creator : 9vult

private void FrmMangaBrowser_FormClosing(object sender, FormClosingEventArgs e)
        {
            browser.Dispose();
        }

19 View Source File : ConnectionManager.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : FButton.cs
License : MIT License
Project Creator : 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 View Source File : Component.cs
License : Mozilla Public License 2.0
Project Creator : ahyahy

public new void Dispose()
        {
            M_Component.Dispose();
        }

19 View Source File : Net40.cs
License : MIT License
Project Creator : 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 View Source File : RemoveInvalidFeature.cs
License : Microsoft Public License
Project Creator : 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 View Source File : RemoveInvalidFeature.cs
License : Microsoft Public License
Project Creator : 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 View Source File : V2rayHandler.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : VssFileStorage.cs
License : MIT License
Project Creator : actions

public void Dispose()
            {
                m_watcher.Dispose();
            }

19 View Source File : DcWebHook.cs
License : MIT License
Project Creator : 1-EXON

public void Dispose()
    {
        dWebClient.Dispose();
    }

19 View Source File : ByteBuffer.cs
License : GNU General Public License v2.0
Project Creator : 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 View Source File : TestEngine.cs
License : MIT License
Project Creator : ab4d

public void Dispose()
		{
			Window.Dispose();
			Device.Dispose();
			SwapChain.Dispose();
			BackBuffer.Dispose();
			RenderTargetView.Dispose();
			Texture.Dispose();
			TextureShaderResourceView.Dispose();
		}

19 View Source File : OperatorContext.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

public void Dispose()
        {
            Command.Dispose();
        }

19 View Source File : FRadioButton.cs
License : MIT License
Project Creator : 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 View Source File : FormAbout.cs
License : GNU General Public License v3.0
Project Creator : AHeroicLlama

private void OkButton_Click(object sender, EventArgs e)
		{
			Close();
			Dispose();
		}

19 View Source File : FormMain.cs
License : MIT License
Project Creator : Abneed

private void salirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

19 View Source File : NoLockTimer.cs
License : MIT License
Project Creator : ABTSoftware

public void Dispose()
        {
            _timer?.Dispose();
        }

19 View Source File : PlatformFileSaveDialog .cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : RemoveInvalidFeature.cs
License : Microsoft Public License
Project Creator : 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 View Source File : MyProgressMonitor.cs
License : Apache License 2.0
Project Creator : 214175590

public override void end()
        {
            timer.Stop();
            timer.Dispose();
            //string note = ("Done in " + elapsed + " seconds!");

            transferEnd(id);
        }

19 View Source File : RemoveInvalidFeature.cs
License : Microsoft Public License
Project Creator : 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 View Source File : RemoveInvalidFeature.cs
License : Microsoft Public License
Project Creator : 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 View Source File : PrivoxyHandler.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : ConsoleUtils.cs
License : GNU Lesser General Public License v3.0
Project Creator : 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 View Source File : FCheckBox.cs
License : MIT License
Project Creator : 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 View Source File : RunnerService.cs
License : MIT License
Project Creator : 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 View Source File : dlgSettings.cs
License : MIT License
Project Creator : 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 View Source File : SuppressionFileWatcherService.cs
License : GNU General Public License v3.0
Project Creator : Acumatica

public void Dispose()
		{
			if (Interlocked.Exchange(ref _instanceDisposed, INSTANCE_DISPOSED) == INSTANCE_UNDISPOSED)
			{			
				_fileSystemWatcher.Dispose();		
			}
		}

19 View Source File : FCheckBox.cs
License : MIT License
Project Creator : 0xLaileb

protected override void OnMouseLeave(EventArgs e)
        {
            timer_effect_1.Stop();
            timer_effect_1.Dispose();
            Mouse_Enter = false;
            temp = 0;

            Refresh();
        }

19 View Source File : DotnetRunFixture.cs
License : MIT License
Project Creator : AdrianWilczynski

public void Dispose()
        {
            _process.CloseMainWindow();
            if (!_process.WaitForExit(TimeSpan.FromSeconds(3).Milliseconds))
            {
                try { _process.Kill(); } catch { }
            }
            _process.Dispose();
        }

19 View Source File : WindowManager.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : ByteBuffer.cs
License : GNU General Public License v2.0
Project Creator : 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 View Source File : ServiceStatusManageService.cs
License : MIT License
Project Creator : 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 View Source File : SqlServerDataBase.cs
License : Mozilla Public License 2.0
Project Creator : 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 View Source File : ProcessResult.cs
License : MIT License
Project Creator : 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 View Source File : SqlServerDataBase.cs
License : Mozilla Public License 2.0
Project Creator : 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 View Source File : SqlServerIo.cs
License : MIT License
Project Creator : 0ffffffffh

private void Close()
        {
            if (conn != null)
            {
                if (Ready)
                    conn.Close();

                conn.Dispose();
                conn = null;
            }
        }

19 View Source File : SsdpClient.cs
License : MIT License
Project Creator : aguang-xyz

public void Dispose()
        {
            _searchTimer.Dispose();
            _checkTimer.Dispose();
            _checkUdpClient.Dispose();
        }

19 View Source File : ProcessExtensions.cs
License : Apache License 2.0
Project Creator : 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 View Source File : MainForm.cs
License : MIT License
Project Creator : 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 View Source File : Watchdog.cs
License : MIT License
Project Creator : 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 View Source File : CelesteNetServer.cs
License : MIT License
Project Creator : 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 View Source File : PlatformFolderBrowserDialog.cs
License : GNU General Public License v3.0
Project Creator : 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 View Source File : TemplateEngin.cs
License : MIT License
Project Creator : 2881099

public void Dispose() {
			_fsw.Dispose();
		}

19 View Source File : RemoveInvalidFeature.cs
License : Microsoft Public License
Project Creator : achimismaili

private void btnScopeCancel_Click(object sender, EventArgs e)
        {
            Log.Information( "Action canceled.");
            this.Close();
            this.Dispose();
        }

See More Examples