public void Run <T1, T2, T3>(RunDelegate <T1, T2, T3> runDelegate, T1 t1, T2 t2, T3 t3) { semaphore.WaitOne(); var t = Task.Run(() => { runDelegate?.Invoke(t1, t2, t3); semaphore.Release(); }); tasks.Add(t); }
public void Run <T>(RunDelegate <T> action, T paras) { semaphore.WaitOne(); var t = Task.Run(() => { action?.Invoke(paras); semaphore.Release(); }); tasks.Add(t); }
public static void Start() { #if !DEBUG try #endif { if (SingleInstanceApplication) { solitude = new Solitude("TheMeldingWars." + Name, CommandHandler); if (!solitude.FirstInstance) { return; } } if (!Common.IsDebugging()) { string[] args = Environment.GetCommandLineArgs(); if (!DataPath.Equals(Path.GetDirectoryName(args[0]), StringComparison.CurrentCultureIgnoreCase)) { string here = args[0]; string there = Path.Combine(DataPath, Name + ".exe"); if (File.Exists(there)) { File.Delete(there); } File.Copy(here, there); Common.Execute(there, Environment.CommandLine); Environment.Exit(0); } } else { Cmd?.Invoke(Environment.GetCommandLineArgs().ToList()); } AppDomain.CurrentDomain.ProcessExit += new EventHandler(ExitHandler); Run?.Invoke(); } #if !DEBUG catch (Exception ex) { ErrorHandler(null, new UnhandledExceptionEventArgs(ex, true)); } #endif }
public static void Main() { ExamplesOnDelegate obj = new ExamplesOnDelegate(); RunDelegate obj1 = () => { Console.WriteLine("Using Lamda Exprssion calls"); }; obj1 += obj.RunFast; obj1 += obj.Run; obj1.Invoke(); RunSlowDelegate obj2 = (string s) => { Console.WriteLine("Lamda Expression"); }; obj2.Invoke("helo"); Console.WriteLine("Example Completed"); Console.ReadKey(); }