private void Finish(StreamPumpResult result) { if (callback != null) { callback.BeginInvoke(this, result, ir => { callback.EndInvoke(ir); }, null); } sem.Release(); }
private void Finish(StreamPumpResult result, StreamPumpCallback callback) { callback?.BeginInvoke(this, result, callback.EndInvoke, null); try { sem.Release(); } catch (ObjectDisposedException) { // ignore } catch (Exception ex) { LogManager.GetLogger(typeof(StreamPump)).Error(ex.Message, ex); } }
private void Finish(StreamPumpResult result, StreamPumpCallback callback) { if (callback != null) { callback.BeginInvoke(this, result, ir => { callback.EndInvoke(ir); }, null); } try { sem.Release(); } catch (ObjectDisposedException) { // ignore } catch (Exception ex) { LogManager.GetLogger(typeof(StreamPump)).Error(ex.Message, ex); } }
private void Finish(StreamPumpResult result, StreamPumpCallback callback) { //https://stackoverflow.com/a/55516918/74071 var task = Task.Run(() => callback(this, result)); task.Wait(); try { sem.Release(); } catch (ObjectDisposedException) { // ignore } catch (Exception ex) { Trace.WriteLine($"StreamPump.Finish Ex [{ ex.Message }]"); } }