예제 #1
0
 public void AttachOnlyOneHandler(Func <string, string> handler)
 {
     lock (someEventLock) {
         if (FormatterEvent != null)
         {
             foreach (var del in FormatterEvent.GetInvocationList())
             {
                 FormatterEvent -= (Func <string, string>)del;
             }
         }
         FormatterEvent += handler;
     }
 }
예제 #2
0
 public void OnSmsReceived(string msg)
 {
     lock (someEventLock) {
         if (MessageBox.InvokeRequired == true)
         {
             this?.BeginInvoke(new SmsProvider.SMSReceivedDelegate(OnSmsReceived), msg);
         }
         else
         {
             msg = FormatterEvent?.Invoke(msg) ?? msg;
             MessageBox.Invoke(new Action(() => MessageBox.AppendText($"{msg}{Environment.NewLine}")));
         }
     }
 }