Exemplo n.º 1
0
 public async Task <bool> SendStringCommandAsync(string command, string arg = null)
 {
     if (_waitHandle != null && !_waitHandle.Released)
     {
         throw new InvalidOperationException();
     }
     _session.SendStringData(command);
     _waitHandle = new AsyncAutoResetEvent <string>();
     return(await _waitHandle.WaitAsync() == "ok");
 }
Exemplo n.º 2
0
        private void SendString(String s)
        {
            if (s == null || s == String.Empty)
            {
                return;
            }

            if (s.Length > MAX_SEND_STRING_LENGTH)
            {
                String msg = String.Format("Cannot send string {0} as it has length {1} > {2}", s, s.Length, MAX_SEND_STRING_LENGTH);
                Tracing?.TraceEvent(TraceEventType.Error, 0, msg);
#if DEBUG
                Debug.Print(msg);
#endif
                return;
            }

            try
            {
                _session.SendStringData(s);
            } catch (Exception e)
            {
                String msg = String.Format("Error sending string {0}: {1} ", e.GetType(), e.Message);
                Tracing?.TraceEvent(TraceEventType.Error, 0, msg);
                throw e;
            }
        }