Exemplo n.º 1
0
        public async Task <MethodResponse> InvokeDirectMethod(string methodName, string parameters)
        {
            MethodResponse methodResponse = new MethodResponse(0);

            _manualResetEvent = new ManualResetEvent(false);

            MethodHandler methodHandler;

            if (_directMethods.TryGetValue(methodName, out methodHandler))
            {
                MethodRequest request = new MethodRequest(methodName, parameters);
                methodResponse = await methodHandler._callback(request, methodHandler._userContext);
            }

            // Wait for SignalOperationComplete() to be called before returning.
            // This is useful for testing async mehtods.

            await Task.Run(() => { _manualResetEvent.WaitOne(5000); });

            _manualResetEvent = null;
            return(methodResponse);
        }
Exemplo n.º 2
0
        public async Task <MethodResponse> InvokeDirectMethod(string name, string parameters)
        {
            MethodResponse result = await _twin.InvokeDirectMethod(name, parameters);

            return(result);
        }