/// <summary> /// 设置返回值 /// </summary> /// <param name="val"></param> /// <returns></returns> public bool SetReturnValue(ZYClient_Result_Return val) { if (AsynRetrunDiy.ContainsKey(val.Id)) { AsynReturn asynRet = new AsynReturn() { ReturnValue = val }; var callback = AsynRetrunDiy[val.Id]; asynRet.Format(callback.ReturnType, callback.ArgsType); AsynRetrunDiy.Remove(val.Id); ThreadPool.QueueUserWorkItem((o) => { callback.Call((AsynReturn)o); }, asynRet); return(true); } else if (ReturnValueDiy.ContainsKey(val.Id)) { WaitReturnValue x = ReturnValueDiy[val.Id]; ReturnValueDiy.Remove(val.Id); x.returnvalue = val; x.waitHandle.Set(); return(true); } return(false); }
/// <summary> /// 设置返回值 /// </summary> /// <param name="val"></param> /// <returns></returns> public bool SetReturnValue(ZYClient_Result_Return val) { if (AsynRetrunDiy.ContainsKey(val.Id)) { AsynReturn asynRet = new AsynReturn() { ReturnValue = val }; var callback = AsynRetrunDiy[val.Id]; asynRet.Format(callback.ReturnType, callback.ArgsType); AsynRetrunDiy.TryRemove(val.Id, out callback); System.Threading.Tasks.Task.Factory.StartNew(() => { callback.Call(asynRet); }).ContinueWith(p => { try { p.Wait(); } catch (Exception er) { if (ErrMsgOut != null) { ErrMsgOut(er.ToString()); } } }); return(true); } else if (ReturnValueDiy.ContainsKey(val.Id)) { var x = ReturnValueDiy[val.Id]; //x.returnvalue = val; //x.IsReturn = true; x.SetResult(val); ReturnValueDiy.TryRemove(val.Id, out x); return(true); } return(false); }
/// <summary> /// 设置返回值 /// </summary> /// <param name="val"></param> /// <returns></returns> public bool SetReturnValue(Result_Have_Return val) { lock (ReturnValueDiy) { if (ReturnValueDiy.ContainsKey(val.Id)) { var x = ReturnValueDiy[val.Id]; x.returnvalue = val; ReturnValueDiy.Remove(val.Id); x.waitHandle.Set(); return(true); } return(false); } }
/// <summary> /// 设置返回值 /// </summary> /// <param name="val"></param> /// <returns></returns> public bool SetReturnValue(ZYClient_Result_Return val) { if (AsynRetrunDiy.ContainsKey(val.Id)) { AsynReturn asynRet = new AsynReturn() { ReturnValue = val }; asynRet.Format(); Action <AsynReturn> callback = AsynRetrunDiy[val.Id]; AsynRetrunDiy.TryRemove(val.Id, out callback); System.Threading.Tasks.Task.Factory.StartNew(() => { callback(asynRet); }).ContinueWith(p => { try { p.Wait(); } catch (Exception er) { if (ErrMsgOut != null) { ErrMsgOut(er.ToString()); } } }); } else if (ReturnValueDiy.ContainsKey(val.Id)) { WaitReturnValue x; ReturnValueDiy.TryRemove(val.Id, out x); x.returnvalue = val; x.waitHandle.Set(); } return(false); }
/// <summary> /// 设置返回值 /// </summary> /// <param name="val"></param> /// <returns></returns> public bool SetReturnValue(ZYClient_Result_Return val) { if (AsynRetrunDiy.ContainsKey(val.Id)) { AsynReturn asynRet = new AsynReturn() { ReturnValue = val }; asynRet.Format(); Action <AsynReturn> callback = AsynRetrunDiy[val.Id]; AsynRetrunDiy.Remove(val.Id); ThreadPool.QueueUserWorkItem((o) => { try { callback((AsynReturn)o); } catch (Exception er) { if (ErrMsgOut != null) { ErrMsgOut(er.ToString()); } } }, asynRet); } else if (ReturnValueDiy.ContainsKey(val.Id)) { WaitReturnValue x = ReturnValueDiy[val.Id]; ReturnValueDiy.Remove(val.Id); x.returnvalue = val; x.waitHandle.Set(); } return(false); }