Example #1
0
        static void Test2()
        {
            FuncVoid func = Hello;

            func.Invoke();
            func = Bye;
            func();

            func  = Hello;
            func += Hi;
            func += Bye;
            func();
        }
Example #2
0
 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));
 }
Example #3
0
        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);
        }
Example #4
0
        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;
        }
Example #5
0
        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);
        }
Example #6
0
 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;
 }
Example #7
0
        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);
        }
Example #8
0
        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;

        }
Example #9
0
        /* 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));
        }
Example #10
0
 public static Thread mtaThread(string threadName, FuncVoid codeToExecute)
 {
     return mtaThread(threadName, codeToExecute, ThreadPriority.Normal);
 }
Example #11
0
 public static Thread mtaThread(FuncVoid codeToExecute, ThreadPriority threadPriority)
 {
     return mtaThread("[O2 Mta Thread]", codeToExecute, threadPriority);
 }
Example #12
0
       /* 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);
        }
Example #13
0
 public static Thread mtaThread(FuncVoid codeToExecute, ThreadPriority threadPriority)
 {
     return(mtaThread("[O2 Mta Thread]", codeToExecute, threadPriority));
 }
Example #14
0
        //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);
        }
Example #15
0
        //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));
        }
Example #16
0
 // ==========================================================
 // Packet Server Shutdown
 // ==========================================================
 public static void SetFuncOnServerShutdown(FuncVoid func)
 {
     NetworkingPlugin_FuncOnServerShutdown(HandleServerShutdown);
     mainThreadServerShutdown = func;
 }
Example #17
0
 public static extern void NetworkingPlugin_FuncOnServerShutdown(FuncVoid func);
Example #18
0
 public static Thread mtaThread(string threadName, FuncVoid codeToExecute)
 {
     return(mtaThread(threadName, codeToExecute, ThreadPriority.Normal));
 }