コード例 #1
0
        T CallAndWait <T>(string callInfo, Func <string, object> convert)
        {
            var remoteCall = new RemoteInvoke(convert);

            lock (_remoteCallLocker)
            {
                _remoteInvokes.Add(remoteCall);
            }
            _subProcess.SendMessage($"$C:{remoteCall.CallId}#{callInfo}");
            if (!remoteCall.Wait())
            {
                throw new TimeoutException();
            }
            return((T)remoteCall.Reasult);
        }
コード例 #2
0
        void ProcessReturn(string returnInfo)
        {
            var          info       = returnInfo.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
            var          id         = info[0];
            var          v          = info[1];
            RemoteInvoke remoteCall = null;

            lock (_remoteCallLocker)
            {
                remoteCall = _remoteInvokes.FirstOrDefault(c => c.CallId == id);
                if (remoteCall != null)
                {
                    _remoteInvokes.Remove(remoteCall);
                }
            }
            remoteCall?.SetReasult(v);
            remoteCall?.Dispose();
        }