Exemple #1
0
        private void SendMessage(string Message, int level = 2)
        {
            CicadaMsg message = new CicadaMsg();

            message.id      = Guid.NewGuid().ToString();
            message.command = "log";
            message.msg     = classMsg + Message;
            message.level   = level;

            StdInAndOut.SendMsg(message);
            //you can also wait the result adopt listen the needAckMessageIds queue.
            //var result = CicadaLaunch.WaitMsgBeAck(message.id, 60000);
        }
Exemple #2
0
        private static Task <bool> StartWaitHeartBeat()
        {
            Task <bool> T = new Task <bool>(() =>
            {
                while (true)
                {
                    try
                    {
                        CicadaMsg msg = StdInAndOut.ReadMsg();
                        if (msg != null)
                        {
                            if (msg.IsHeartBeat())
                            {
                                StdInAndOut.Sync();
                            }
                            else if (msg.command == "ack" && !string.IsNullOrWhiteSpace(msg.id))
                            {
                                DateTime startTime;
                                needAckMessageIds.TryRemove(msg.id, out startTime);
                            }
                        }
                        else
                        {
                            Thread.Sleep(50);
                        }
                    }
                    catch (Exception ex)
                    {
                        Thread.Sleep(50);
                        //do some thing and log it.
                    }
                }
            });

            return(T);
        }