public void SendTo(byte[] messageData, UdpEndPoint endPoint) { if (messageData == null) { throw new ArgumentNullException("messageData"); } if (endPoint == null) { throw new ArgumentNullException("endPoint"); } ThrowIfDisposed(); var signal = new System.Threading.ManualResetEvent(false); try { _UdpClient.BeginSendToGroup(messageData, 0, messageData.Length, (asyncResult) => { _UdpClient.EndSendToGroup(asyncResult); signal.Set(); } , null ); signal.WaitOne(); } finally { signal.Dispose(); } }
/// <summary> /// Libera a instancia. /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (_waitHandle != null) { _waitHandle.Dispose(); } }
void IDisposable.Dispose() { if (IsRunning) { Stop(); _executeTask.Wait(); } if (Browser != null) { Browser.LoadingStateChanged -= Browser_LoadingStateChanged; Browser.FrameLoadStart -= Browser_FrameLoadStart; Browser.FrameLoadEnd -= Browser_FrameLoadEnd; Browser = null; } if (_executeTask != null) { _executeTask.Dispose(); _executeTask = null; } if (_breakEvent != null) { _continueEvent.Dispose(); _continueEvent = null; } if (_continueEvent != null) { _continueEvent.Dispose(); _continueEvent = null; } if (_frameLoadEvent != null) { _frameLoadEvent.Dispose(); _frameLoadEvent = null; } if (_pageLoadEvent != null) { _pageLoadEvent.Dispose(); _pageLoadEvent = null; } }
public void Dispose() { #if !CONTRACTS_ONLY if (!_IsDisposed) { #if SUPPORTS_APPDOMAIN AppDomain.CurrentDomain.DomainUnload -= CurrentDomain_DomainUnload; AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException; AppDomain.CurrentDomain.ProcessExit -= CurrentDomain_ProcessExit; #endif _IsDisposed = true; _BufferTimeoutTimer?.Dispose(); _WriteBufferedEventsSignal?.Set(); WaitForBackgroundThreadToExit(); (_LogWriter as IDisposable)?.Dispose(); _WriteBufferedEventsSignal?.Dispose(); var emptySignal = _QueueEmptySignal; _QueueEmptySignal = null; emptySignal?.Dispose(); _LogEventPool?.Dispose(); } #endif }
private static UdpAnySourceMulticastClient CreateMulticastClientAndJoinGroup(string ipAddress, int localPort) { var retVal = new UdpAnySourceMulticastClient(IPAddress.Parse(ipAddress), localPort); var signal = new System.Threading.ManualResetEvent(false); try { retVal.BeginJoinGroup( (joinResult) => { retVal.EndJoinGroup(joinResult); retVal.MulticastLoopback = true; retVal.SendBufferSize = retVal.ReceiveBufferSize = SsdpConstants.DefaultUdpSocketBufferSize; signal.Set(); }, null); signal.WaitOne(); } finally { signal.Dispose(); } return(retVal); }
public void Dispose() { if (m_bIsDisposed == false) { GotEvent.Close(); GotEvent.Dispose(); m_bIsDisposed = true; } }
// Clean up any resources being used. protected override void Dispose(bool disposing) { if (disposing) { fAbortEvent.Dispose(); fInitEvent.Dispose(); if (components != null) { components.Dispose(); } } base.Dispose(disposing); }
public void Dispose() { if (1 == Interlocked.Exchange(ref _Disposed, 1)) { return; } try { if (_started) { _running = false; _haveWork.Set(); if (!_finished.WaitOne(100)) { _thread.Abort(); _finished.WaitOne(); } } if (null != _startedSignal) { _startedSignal.Dispose(); } if (null != _finished) { _finished.Dispose(); } if (null != _haveWork) { _haveWork.Dispose(); } _startedSignal = null; _finished = null; _haveWork = null; _thread = null; _work = null; } catch (Exception) { } GC.SuppressFinalize(this); }
public override void InvokeShortcut(int which, global::WriteLogClrTypes.IWriteL wl) { if ((which < 0) || (which >= CommandNames.Length)) { throw new IndexOutOfRangeException(); } if (!m_running) { // put the .NET gui on its own thread. It "works" on WriteLog's main thread, // but the .NET clr has some GUI keyboard features that only work properly if // the clr has that gui's message loop. so...here we go... System.Threading.ManualResetEvent ev = new System.Threading.ManualResetEvent(false); guiThread = new System.Threading.Thread(() => GuiThreadEntry(ev)); guiThread.Start(); ev.WaitOne(); // inside the form, on its FormLoad handler, this event is set. ev.Dispose(); } m_doShortcut?.Invoke(which); }
public AssemblyPackageContainer GetAssemblyPackages(IEnumerable <AssemblyPart> assemblyParts) { var allDone = new System.Threading.ManualResetEvent(false); var asyncResult = new Threading.AsyncResult <AssemblyPackageContainer>(ar => { try { allDone.Set(); } catch (System.IO.IOException) { try { allDone.Dispose(); } catch { } } }, null); var arguments = new object[] { asyncResult, assemblyParts }; DoGetAssemblyPackages(arguments); try { allDone.WaitOne(); } catch (ObjectDisposedException) { } if (asyncResult.Exception != null) { throw asyncResult.Exception; } return(asyncResult.Result); }
public void SendTo(byte[] messageData, UdpEndPoint endPoint) { if (messageData == null) throw new ArgumentNullException("messageData"); if (endPoint == null) throw new ArgumentNullException("endPoint"); ThrowIfDisposed(); var signal = new System.Threading.ManualResetEvent(false); try { _UdpClient.BeginSendToGroup(messageData, 0, messageData.Length, (asyncResult) => { _UdpClient.EndSendToGroup(asyncResult); signal.Set(); } , null ); signal.WaitOne(); } finally { signal.Dispose(); } }
public void StopListeningForResponses() { _ReceivedMessageQueue.Clear(); _MessageAvailableSignal.Dispose(); _MessageAvailableSignal = new System.Threading.ManualResetEvent(false); }
public void StopListeningForBroadcasts() { _ReceivedBroadcastsQueue.Clear(); _BroadcastAvailableSignal.Dispose(); _BroadcastAvailableSignal = new System.Threading.ManualResetEvent(false); }
/// <summary> /// Libera a instancia. /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { _allDone.Dispose(); }
public void Dispose() { gate.Dispose(); }
/// <inheritdoc/> public void Dispose() { _canProcessEvents.Dispose(); _queue.Dispose(); }
private static UdpAnySourceMulticastClient CreateMulticastClientAndJoinGroup(string ipAddress, int localPort) { var retVal = new UdpAnySourceMulticastClient(IPAddress.Parse(ipAddress), localPort); var signal = new System.Threading.ManualResetEvent(false); try { retVal.BeginJoinGroup( (joinResult) => { retVal.EndJoinGroup(joinResult); retVal.MulticastLoopback = true; retVal.SendBufferSize = retVal.ReceiveBufferSize = SsdpConstants.DefaultUdpSocketBufferSize; signal.Set(); }, null); signal.WaitOne(); } finally { signal.Dispose(); } return retVal; }