private async void LoustWindow_TickAsync(object sender, EventArgs e) { UiSynchronizationContext.Send(x => UpdateUiThreadLastActiveAt(), null); if (vStatusLastConfirmedAt == vUiThreadLastActiveAt) { return; } var statusCode = await TashAccessor.ConfirmAliveAsync(vProcessId, vUiThreadLastActiveAt, ControllableProcessStatus.Busy); if (statusCode == HttpStatusCode.NoContent) { vStatusLastConfirmedAt = vUiThreadLastActiveAt; UiSynchronizationContext.Post(x => ShowLastCommunicatedTimeStamp(), null); return; } UiSynchronizationContext.Post(x => { CommunicateCouldNotConfirmStatusToTashThenStop(statusCode); }, null); }
public async Task CanConfirmAliveness() { await LaunchTashAppIfNotRunning(); var currentProcess = Process.GetCurrentProcess(); var statusCode = await _Sut.PutControllableProcessAsync(currentProcess); Assert.IsTrue(statusCode == HttpStatusCode.Created || statusCode == HttpStatusCode.NoContent); var now = DateTime.Now.AddHours(1); statusCode = await _Sut.ConfirmAliveAsync(currentProcess.Id, now, ControllableProcessStatus.Busy); Assert.AreEqual(HttpStatusCode.NoContent, statusCode); var process = await _Sut.GetControllableProcessAsync(currentProcess.Id); Assert.IsNotNull(process); Assert.AreEqual(now, process.ConfirmedAt); Assert.AreEqual(ControllableProcessStatus.Busy, process.Status); }