private void _edgeAgent_MessageReceived(object sender, MessageReceivedEventArgs e)
        {
            switch (e.Type)
            {
            case MessageType.WriteValue:
                WriteValueCommand wvcMsg = ( WriteValueCommand )e.Message;
                foreach (var device in wvcMsg.DeviceList)
                {
                    Console.WriteLine("DeviceId: {0}", device.Id);
                    foreach (var tag in device.TagList)
                    {
                        Console.WriteLine("TagName: {0}, Value: {1}", tag.Name, tag.Value.ToString());
                        if (device.Id == "Device1" && tag.Name == "DTag1")
                        {
                            if (this.txtDTag1Value.InvokeRequired)
                            {
                                BeginInvoke((MethodInvoker) delegate()
                                {
                                    txtDTag1Value.Text = tag.Value.ToString();
                                });
                            }
                            // resend the new value to cloud
                            EdgeData     data = new EdgeData();
                            EdgeData.Tag dTag = new EdgeData.Tag()
                            {
                                DeviceId = "Device1",
                                TagName  = "DTag1",
                                Value    = tag.Value
                            };
                            data.TagList.Add(dTag);
                            data.Timestamp = DateTime.Now;
                            bool result = _edgeAgent.SendData(data).Result;
                        }
                    }
                }
                break;

            /*case MessageType.WriteConfig:
             *  break;*/
            case MessageType.ConfigAck:
                ConfigAck cfgAckMsg = ( ConfigAck )e.Message;
                MessageBox.Show(string.Format("Upload Config Result: {0}", cfgAckMsg.Result.ToString()));
                break;
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (_edgeAgent == null)
            {
                return;
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Reset();
            sw.Start();

            EdgeData data   = prepareData();
            bool     result = _edgeAgent.SendData(data).Result;

            sw.Stop();
            Console.WriteLine(sw.Elapsed.TotalMilliseconds.ToString());
        }