public void FinishWrite(BaseDocument baseDocument) { IAsyncResult ar = UnlockAsync(baseDocument); if (!ar.IsCompleted) { ar.AsyncWaitHandle.WaitOne() ; } }
public static async Task LockAsync(BaseDocument baseDocument) { requestObject.ActionType = ActionType.Lock; requestObject.LockedBy = 1; requestObject.RowId = baseDocument.Id; var json = JsonConvert.SerializeObject(requestObject); var data = new StringContent(json, Encoding.UTF8, "application/json"); using var client = new HttpClient(); //client.Timeout = TimeSpan.FromMinutes(5); var response = await client.PostAsync(lockRoute, data); bool result = Convert.ToBoolean(response.Content.ReadAsStringAsync().Result); Console.WriteLine(result); }