public void DataSenderTest() { var au = new AutoResetEvent(false); ConnectionBase testInterface = new TestInterface(); for (int x = 0; x < 100; x++) { var testData = new TestPw(); var ds = new DataSender(testInterface, testData); ds.Start(); var error = ds.ErrorMessage; var succes = ds.SendComplete; Assert.IsTrue(succes); Assert.IsTrue(testData.ModuleDataCheckOk); } }
private async void Send(IDispatchData data) { var ds = new DataSender(_interf, data); WeakEventManager<DataQueue, EventArgs>.AddHandler(this, GenericMethods.GetPropertyName(() => Cancel), ds.Stop); data.Error += data_Error; ds.Start(); var succes = await ds.SendCompleteAsync(); if (succes) { _queueState.Fire(QueueEvent.DataSend); } else { data_Error(data, new ErrorEventArgs { Exception = new Exception("receive failed " + ds.ErrorMessage) }); } data.Error -= data_Error; }