public static byte[] SendFile(byte[] dataToPredict, ushort selectedAlgortihm, AsynchronousClient client) { try { byte[] requestBytes = CreateFTRequestBytes(dataToPredict, selectedAlgortihm); using (client) { client.ExceptionReport += (sender, e) => { client.Dispose(); //window.Dispatcher.BeginInvoke((MethodInvoker)(() => // MessageBox.Show(e.Exception.Message, Application.ProductName, // MessageBoxButtons.OK, MessageBoxIcon.Error))); }; client.Connect(Dns.GetHostName()); client.SendData(requestBytes); var result = client.ReceiveResponse(); return(result); } } catch (Exception ex) { throw ex; } }
protected virtual void Dispose(bool disposing) { if (!IsDisposed) { //EventManager.RaiseOnMainThread(EventType.EndWork, true); IsDisposed = true; if (disposing) { ResetSubscription(); Client?.Dispose(); } } }