static void Test2() { FuncVoid func = Hello; func.Invoke(); func = Bye; func(); func = Hello; func += Hi; func += Bye; func(); }
public HandlerService(string dLLPath) { if (!File.Exists(dLLPath)) { throw new Exception("Handler dll is missing, please contact the developer!"); } dll = new CppInvoke(dLLPath); loadFunction = (FuncVoid)dll.Invoke("Setup", typeof(FuncVoid)); startFunction = (FuncVoid)dll.Invoke("Start", typeof(FuncVoid)); eotFunction = (FuncIntArray)dll.Invoke("EOTProcess", typeof(FuncIntArray)); stopFunction = (FuncVoid)dll.Invoke("Stop", typeof(FuncVoid)); unloadFunction = (FuncVoid)dll.Invoke("Reset", typeof(FuncVoid)); }
public static Thread staThread(FuncVoid codeToExecute, ThreadPriority threadPriority) { var stackTrace = getCurrentStackTrace(); // used for cross thread debugging purposes var staThread = new Thread(() => { try { codeToExecute(); } catch (Exception ex) { ex.log("in staThread"); } }); staThread.SetApartmentState(ApartmentState.STA); staThread.Priority = threadPriority; staThread.Start(); return(staThread); }
public static Thread staThread(FuncVoid codeToExecute, ThreadPriority threadPriority) { var stackTrace = getCurrentStackTrace(); // used for cross thread debugging purposes var staThread = new Thread(()=>{ try { codeToExecute(); } catch (Exception ex) { ex.log("in staThread"); } }); staThread.SetApartmentState(ApartmentState.STA); staThread.Priority = threadPriority; staThread.Start(); return staThread; }
public static Thread mtaThread(Semaphore semaphore, FuncVoid codeToExecute) { var stackTrace = getCurrentStackTrace(); // used for cross thread debugging purposes if (semaphore == null) { return(mtaThread(codeToExecute)); } // if no use the mtaThread function with no semaphore support var _mtaThread = new Thread(() => { semaphore.WaitOne(); codeToExecute(); semaphore.Release(); }); _mtaThread.SetApartmentState(ApartmentState.MTA); _mtaThread.Start(); return(_mtaThread); }
public static Thread mtaThread(string threadName, FuncVoid codeToExecute, ThreadPriority threadPriority) { var stackTrace = getCurrentStackTrace(); // used for cross thread debugging purposes var mtaThread = new Thread(() => { try { codeToExecute(); } catch (Exception ex) { DI.log.ex(ex,"in mtaThread", true); } }) // Thread() contructor { Name = threadName }; mtaThread.SetApartmentState(ApartmentState.MTA); mtaThread.Priority = threadPriority; mtaThread.Start(); return mtaThread; }
public static Thread mtaThread(string threadName, FuncVoid codeToExecute, ThreadPriority threadPriority) { var stackTrace = getCurrentStackTrace(); // used for cross thread debugging purposes var mtaThread = new Thread(() => { try { codeToExecute(); } catch (Exception ex) { DI.log.ex(ex, "in mtaThread", true); } }) // Thread() contructor { Name = threadName }; mtaThread.SetApartmentState(ApartmentState.MTA); mtaThread.Priority = threadPriority; mtaThread.Start(); return(mtaThread); }
public static Thread mtaThread(Semaphore semaphore, FuncVoid codeToExecute) { var stackTrace = getCurrentStackTrace(); // used for cross thread debugging purposes if (semaphore == null) return mtaThread(codeToExecute); // if no use the mtaThread function with no semaphore support var _mtaThread = new Thread(() => { semaphore.WaitOne(); codeToExecute(); semaphore.Release(); }); _mtaThread.SetApartmentState(ApartmentState.MTA); _mtaThread.Start(); return _mtaThread; }
/* public static void mtaThreadSync(FuncVoid codeToExecute) * { * var thread = mtaThread(codeToExecute); * thread.Join(); * if (thread.IsAlive) * { * } * }*/ public static Thread mtaThread(FuncVoid codeToExecute) { return(mtaThread("[O2 Mta Thread]", codeToExecute)); }
public static Thread mtaThread(string threadName, FuncVoid codeToExecute) { return mtaThread(threadName, codeToExecute, ThreadPriority.Normal); }
public static Thread mtaThread(FuncVoid codeToExecute, ThreadPriority threadPriority) { return mtaThread("[O2 Mta Thread]", codeToExecute, threadPriority); }
/* public static void mtaThreadSync(FuncVoid codeToExecute) { var thread = mtaThread(codeToExecute); thread.Join(); if (thread.IsAlive) { } }*/ public static Thread mtaThread(FuncVoid codeToExecute) { return mtaThread("[O2 Mta Thread]", codeToExecute); }
public static Thread mtaThread(FuncVoid codeToExecute, ThreadPriority threadPriority) { return(mtaThread("[O2 Mta Thread]", codeToExecute, threadPriority)); }
//var threadEnded = new AutoResetEvent(false); /*public static void staThreadSync(FuncVoid codeToExecute) { var thread = staThread(codeToExecute); thread.Join(); if (thread.IsAlive) { } }*/ public static Thread staThread(FuncVoid codeToExecute) { return staThread(codeToExecute, ThreadPriority.Normal); }
//var threadEnded = new AutoResetEvent(false); /*public static void staThreadSync(FuncVoid codeToExecute) * { * var thread = staThread(codeToExecute); * thread.Join(); * if (thread.IsAlive) * { * } * }*/ public static Thread staThread(FuncVoid codeToExecute) { return(staThread(codeToExecute, ThreadPriority.Normal)); }
// ========================================================== // Packet Server Shutdown // ========================================================== public static void SetFuncOnServerShutdown(FuncVoid func) { NetworkingPlugin_FuncOnServerShutdown(HandleServerShutdown); mainThreadServerShutdown = func; }
public static extern void NetworkingPlugin_FuncOnServerShutdown(FuncVoid func);
public static Thread mtaThread(string threadName, FuncVoid codeToExecute) { return(mtaThread(threadName, codeToExecute, ThreadPriority.Normal)); }