Advertisement
Guest User

Code for UI action invocation in WinForms (C#)

a guest
Oct 31st, 2012
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 KB | None | 0 0
  1.         public void Invoke<U>(Action<U> action, U args)
  2.         {
  3.             try
  4.             {
  5.                 Helpers.InvokeAction(this, action, args);
  6.             }
  7.             catch (Exception)
  8.             {
  9.             }
  10.         }
  11.         public void Invoke<U>(Action<U[]> action, U arg1, U arg2)
  12.         {
  13.             try
  14.             {
  15.                 Helpers.InvokeAction(this, action, new U[] { arg1, arg2 });
  16.             }
  17.             catch (Exception)
  18.             {
  19.             }
  20.         }
  21.         public void Invoke<U>(Action<U[]> action, U arg1, U arg2, U arg3)
  22.         {
  23.             try
  24.             {
  25.                 Helpers.InvokeAction(this, action, new U[] { arg1, arg2, arg3 });
  26.             }
  27.             catch (Exception)
  28.             {
  29.             }
  30.         }
  31.         public void Invoke<U>(Action<U[]> action, U arg1, U arg2, U arg3, U arg4)
  32.         {
  33.             try
  34.             {
  35.                 Helpers.InvokeAction(this, action, new U[] { arg1, arg2, arg3, arg4 });
  36.             }
  37.             catch (Exception)
  38.             {
  39.             }
  40.         }
  41.         public void Invoke<U>(Action<U[]> action, params U[] args)
  42.         {
  43.             try
  44.             {
  45.                 Helpers.InvokeAction(this, action, args);
  46.             }
  47.             catch (Exception)
  48.             {
  49.             }
  50.         }
  51.         public void Invoke(Action action, bool raiseError = true)
  52.         {
  53.             if (running)
  54.             {
  55.                 try
  56.                 {
  57.                     Helpers.InvokeAction(this, action);
  58.                     return;
  59.                 }
  60.                 catch (ObjectDisposedException)
  61.                 {
  62.                     running = false;
  63.                 }
  64.                 catch (Exception)
  65.                 {
  66.                     if (raiseError)
  67.                     {
  68.                         throw new LasException("Выполнение приложения прервано");
  69.                     }
  70.                 }
  71.             }
  72.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement