private void startTelemetryLoop(object msg) { m_TelemetryTask = new Task(() => { m_Transport.RegisterAcknowledge((msgId, err) => { m_TraceMethod(String.Format("Ackowledge of message received for MessageId: {0}", msgId)); }); while (m_IsStopRequested == false) { Task.Delay(5000); TelemetryData sensorEvent = new TelemetryData() { Device = m_Id, Temperature = DateTime.Now.Minute, }; m_Transport.SendAsync(sensorEvent, (sentMessages) => { }, (failedMessages, err) => { }, m_SndAckArgs).Wait(); } m_IsStopRequested = false; }); m_TelemetryTask.Start(); }
public async Task SendAsync(object sensorMessage, Action <IList <object> > onSuccess = null, Action <IList <object>, Exception> onError = null, Dictionary <string, object> args = null) { await Task.Run(() => { m_Connector.SendAsync(sensorMessage, onSuccess, onError, args).Wait(); }); }