/// <summary> /// Write the value to the ServerPadInt in the object server /// </summary> /// <param name="value"></param> public void Write(int value) { try { if (PADI_Client.TransactionId != 0) { if (worker.IsThisServerFreezed) { AsyncWritePadInt write = new AsyncWritePadInt(worker.Write); AsyncCallback writeCallback = new AsyncCallback(AsyncWriteCallBack); IAsyncResult RemAr = write.BeginInvoke(this.UID, PADI_Client.TransactionId, value, writeCallback, null); Console.WriteLine("Write will be delayed due to server freeze."); } else { worker.Write(this.UID, PADI_Client.TransactionId, value); } } else { throw new TxException("Transaction is required to be started before write operation"); } } catch (TxException ex) { Common.Logger().LogError(ex.Message, ex.StackTrace, ex.Source); throw ex; } }
/// <summary> /// Write request will be requested here /// </summary> /// <param name="ar"></param> public void AsyncWriteCallBack(IAsyncResult ar) { try { AsyncWritePadInt del = (AsyncWritePadInt)((AsyncResult)ar).AsyncDelegate; Console.WriteLine("Write successful"); } catch (TxException ex) { Console.WriteLine(ex.Message); throw ex; } catch (Exception ex) { Console.WriteLine(ex.Message); throw ex; } }