private void CloseThis() { if (CloseIt?.Invoke(this) == true) { Content?.Close(); } }
private async void CloseThis() { if (await CloseIt?.Invoke(this) == true) { Content?.Close(); } }
/// <summary> /// 关闭到客户端的连接而不发送响应。 /// </summary> public void Close() { _closeAction?.Invoke(); _closeAction = null; #if net40 _closeAsycAction?.Invoke(); _closeAsycAction = null; #endif _isClientConnectedAction = null; }
/// <summary> /// Подпрограмма завершения работы с платой /// </summary> /// <returns></returns> // ReSharper disable once UnusedMethodReturnValue.Global public int Close() { // Synchronously wait to enter the Semaphore. SemaphoreSlim.Wait(); var error = _close?.Invoke(ref _device) ?? int.MaxValue; if (_dllhandle != IntPtr.Zero) { // Free resources. // Probably should use SafeHandle or some similar class, but this will do for now. NativeMethods.FreeLibrary(_dllhandle); } // Release the Semaphore. SemaphoreSlim.Release(); return(error); }