private T WaitResponse <T>() { try { lock (locker) { if (!isBlocked) { isBlocked = true; System.Threading.Monitor.Wait(locker); } isBlocked = false; if (isError) { throw new Exception("Превышено время ожидания ответа от сервера"); } return(ClientAuction.DeserializeFromString <T>(Response)); } } catch (Exception ex) { MessageBox.Show(ex.Message); throw (ex); } }
public Task <T> WaitResponseAsync <T>() { try { //TimerSet(); return(Task.Run(async() => { if (!isBlocked) { isBlocked = true; await PWaitResponseAsync(); } isBlocked = false; if (isError) { throw new Exception("Превышено время ожидания ответа от сервера"); } return ClientAuction.DeserializeFromString <T>(Response); })); } catch (Exception ex) { MessageBox.Show(ex.Message); throw (ex); } }
public string GetPhoto() { try { string message = GetFirstMessage(); ClientAuction.IsRecieveImage = true; methods.CreateRequest("GetPhotoSt2"); ClientAuction.RecieveImage(ClientAuction.DeserializeFromString <int>(message)); methods.Response = "true"; methods.PulseLocker(); return(null); } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } }