Example #1
0
        private void testCMCore(int s, int t)
        {
            bool i = false;

            try
            {
                if (t == 0 ? myMutex.WaitForMutex(): myMutex.WaitForMutex(t))
                {
                    i = true;
                    while (true)
                    {
                        CrestronConsole.PrintLine("*** Mutex {0} Running ***", s);
                    }
                }
                else
                {
                    i = false;
                    CrestronConsole.PrintLine("*** Mutex {0} Timed Out {1}ms ***", s, t);
                }
            }
            catch (Exception e)
            {
                CrestronConsole.PrintLine("*** Error: {0} - {1} ***", s, e.Message);
            }
            finally
            {
                if (i)
                {
                    myMutex.ReleaseMutex();
                }
            }
        }
        void OnTimer(Object o)
        {
            bMutex.WaitForMutex();
//            CrestronConsole.PrintLine("Ping!");
            if (Buffer.Length > 0)
            {
                try
                {
                    {
                        int l = (Buffer.Length > nChunk_Size) ? nChunk_Size : Buffer.Length;

                        String s = Buffer.ToString(0, l);
                        Buffer.Remove(0, l);
//                        CrestronConsole.PrintLine("Dechunk {0}", s);
                        if (OnChunk != null)
                        {
                            OnChunk(s);
                        }
                    }
                }
                catch (Exception e)
                {
                    CrestronConsole.PrintLine(e.Message);
                    CrestronConsole.PrintLine(e.StackTrace);
                }
            }
            bMutex.ReleaseMutex();
        }
Example #3
0
 void SendTelegramToKnx()
 {
     if (SendQueue.Count > 0)
     {
         bMutex.WaitForMutex();
         try
         {
             string sout = SendQueue.Dequeue();
             if ((!string.IsNullOrEmpty(sout)) && (OnSend != null))
             {
                 OnSend(sout);
             }
         }
         catch (Exception e)
         {
             Logger.Log("SendTelegramToKnx: {0}", e.Message);
         }
         finally
         {
             bMutex.ReleaseMutex();
         }
     }
 }
Example #4
0
 public void ReleaseMutex()
 {
     cm.ReleaseMutex();
 }
Example #5
0
 /// <summary>
 /// Manually release the lock.
 /// (Note: This is done automatically when the LockToken is disposed)
 /// </summary>
 public void ReleaseLock()
 {
     _mutex.ReleaseMutex();
 }