public TestTransparentProxyFactory(object targetInstance, Type targetType, InvokeCallback invokeHandler) : base(typeof(MarshalByRefObject)) { this.targetInstance = targetInstance; this.targetType = targetType; this.invokeHandler = invokeHandler; }
private void AppendOutputString(String msg) { if (outputWindow.InvokeRequired) { InvokeCallback msgCallback = new InvokeCallback(AppendOutputString); // If use Invoke here, program will hang. outputWindow.BeginInvoke(msgCallback, new object[] { msg }); } else { outputWindow.Text += (Environment.NewLine + msg); } }
public string Invoke(string identifier, UInt32 version, byte[] payload, InvokeCallback cb) { return Invoke(identifier, version, payload, cb, 30000); }
public string Invoke(string identifier, UInt32 version, byte[] payload, InvokeCallback cb, int timeoutMs) { if (isConnecting || !isReady) { try { cb(ErrorCodes.INTERNAL_SERVER_ERROR, null, "ESB client not connected"); } catch (Exception e) { log.ErrorFormat("Exception in invoke callback: {0}", e.ToString()); } return string.Empty; } if (log.IsDebugEnabled) log.DebugFormat("Invoke()"); string cmdGuid = genGuid(); var s = new ResponseStruct { callback = (errCode, data, err) => { try { cb(errCode, data, err); } catch (Exception e) { log.ErrorFormat("Exception in invoke callback: {0}", e.ToString()); } }, reqTime = DateTime.Now.AddMilliseconds(timeoutMs) }; var msgReq = new Message { cmd = Message.Cmd.INVOKE, source_operation_guid = cmdGuid, identifier = identifier + "/v" + version, payload = payload, source_component_guid = guid }; //responsesMutex.WaitOne(); while (!responses.TryAdd(cmdGuid, s)) Thread.Sleep(1); //responsesMutex.ReleaseMutex(); publisher.Publish(proxyGuid, ref msgReq); return cmdGuid; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public void invokeWithCallback(final Connection conn, final Object request, final InvokeContext invokeContext, final InvokeCallback invokeCallback, final int timeoutMillis) throws exception.RemotingException //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: public override void invokeWithCallback(Connection conn, object request, InvokeContext invokeContext, InvokeCallback invokeCallback, int timeoutMillis) { rpcRemoting.invokeWithCallback(conn, request, invokeContext, invokeCallback, timeoutMillis); }
//MARSHAL CALLS FROM Non-UI Thread to UI Thread [DllImport(DllName, CallingConvention = CallingConvention.Cdecl, SetLastError = true)] static extern void Photino_Invoke(IntPtr instance, InvokeCallback callback);
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public void invokeWithCallback(final String address, final Object request, final InvokeContext invokeContext, final InvokeCallback invokeCallback, final int timeoutMillis) throws exception.RemotingException, ThreadInterruptedException //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: public override void invokeWithCallback(string address, object request, InvokeContext invokeContext, InvokeCallback invokeCallback, int timeoutMillis) { rpcRemoting.invokeWithCallback(address, request, invokeContext, invokeCallback, timeoutMillis); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public void invokeWithCallback(final Url url, final Object request, final InvokeContext invokeContext, final InvokeCallback invokeCallback, final int timeoutMillis) throws exception.RemotingException, ThreadInterruptedException //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: public override void invokeWithCallback(Url url, object request, InvokeContext invokeContext, InvokeCallback invokeCallback, int timeoutMillis) { rpcRemoting.invokeWithCallback(url, request, invokeContext, invokeCallback, timeoutMillis); }
private void CancelTemplate(InvokeCallback invoke, TestCallback proceed, TestCallback verify) { this.TestTemplate( invoke, (mock, service, asyncResult) => { proceed(mock, service, asyncResult); mock.DomainClient.RequestCallback(); Assert.IsTrue(mock.DomainClient.CancellationRequested, "Result should be canceled."); }, verify, false); this.TestTemplate( invoke, (mock, service, asyncResult) => { proceed(mock, service, asyncResult); mock.DomainClient.RequestCallback(WebAuthenticationServiceTest.Delay); this.EnqueueCallback(() => { Assert.IsTrue(mock.DomainClient.CancellationRequested, "Result should be canceled."); }); }, verify, false); this.EnqueueTestComplete(); }
/// <summary> /// Bild (oder Bilder?) fertig gescannt? /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Controller_ScannedAll(object sender, ScannedAllEventArgs e) { string savename=String.Format("{0}{1}.png", Globals.OptionsTempDirectory, CSCL.Helpers.StringHelpers.GetRandomASCIIString(8)); Image scannedPicture = e.Images[0]; scannedPicture.Save(savename); savepathInvoke=savename; InvokeCallback RefreshListCallback=new InvokeCallback(RefreshList); lbImageData.Invoke(RefreshListCallback); }
/// <summary> /// Constructor. /// </summary> /// <param name="invokeId"> invoke id </param> /// <param name="callbackListener"> callback listener </param> /// <param name="callback"> callback </param> /// <param name="protocol"> protocol </param> /// <param name="commandFactory"> command factory </param> /// <param name="invokeContext"> invoke context </param> public DefaultInvokeFuture(int invokeId, InvokeCallbackListener callbackListener, InvokeCallback callback, byte protocol, CommandFactory commandFactory, InvokeContext invokeContext) : this(invokeId, callbackListener, callback, protocol, commandFactory) { this.invokeContext = invokeContext; }
internal void BeginInvoke(InvokeCallback callback) { BeginInvoke((Delegate)callback); }
/// <summary> /// Constructor. /// </summary> /// <param name="invokeId"> invoke id </param> /// <param name="callbackListener"> callback listener </param> /// <param name="callback"> callback </param> /// <param name="protocol"> protocol code </param> /// <param name="commandFactory"> command factory </param> public DefaultInvokeFuture(int invokeId, InvokeCallbackListener callbackListener, InvokeCallback callback, byte protocol, CommandFactory commandFactory) { invokeId_Renamed = invokeId; this.callbackListener = callbackListener; this.callback = callback; this.protocol = protocol; this.commandFactory = commandFactory; }
/// <summary> /// Invoke the native method. /// </summary> /// <param name="reactInstance">The React instance.</param> /// <param name="arguments">The arguments.</param> /// <returns>The native method result.</returns> public JToken Invoke(InvokeCallback reactInstance, JArray arguments) { return(_func(reactInstance, arguments)); }
/// <summary> /// Invokes a remote method asynchronously. /// </summary> /// <param name="method">Name of the remote method to invoke.</param> /// <param name="parameters">The list of paramenters to pass to the method.</param> /// <param name="callback">Callback method that will be called once a response is received.</param> /// <remarks> /// This is the only invokation method directly exposed by <see cref="Client" />. /// Use various extension methods that provide more specific invokation functionality. /// </remarks> public void InvokeAsync(string method, object[] parameters, InvokeCallback callback) { Channel ch = OpenChannel(null); ch.MessageRecieved += (sender, args) => { string name = args.Event.Name; switch (name) { case "ERR": var data = args.Event.Args; if (data.Count != 3) { RaiseError("ProtocolError", "Invalid event: Bad error"); return; } callback?.BeginInvoke(new ErrorInformation(data[0].AsString(), data[1].AsString(), data[2].AsString()), null, false, null, null); CloseChannel(ch); break; case "OK": callback?.BeginInvoke(null, ArgumentUnpacker.Unpack(args.Event.Args[0]), false, null, null); CloseChannel(ch); break; case "STREAM": callback?.BeginInvoke(null, ArgumentUnpacker.Unpack(args.Event.Args), true, null, null); break; case "STREAM_DONE": callback?.BeginInvoke(null, null, false, null, null); CloseChannel(ch); break; default: callback?.BeginInvoke(new ErrorInformation("ProtocolError", "Invalid event: unknown name"), null, false, null, null); CloseChannel(ch); break; } }; ch.Error += (sender, args) => callback?.BeginInvoke(args.Info, null, false, null, null); ch.StartTimeoutWatch(timeout, () => { string timeoutErrorName = "TimeoutExpired"; string timeoutErrorMessage = $"Timeout after {timeout.TotalMilliseconds} ms"; RaiseError(timeoutErrorName, timeoutErrorMessage); callback?.BeginInvoke(new ErrorInformation(timeoutErrorName, timeoutErrorMessage), null, false, null, null); CloseChannel(ch); }); ch.Send(method, parameters); }
public string Invoke(string identifier, UInt32 version, byte[] payload, InvokeCallback cb) { return(Invoke(identifier, version, payload, cb, 30000)); }
private void ErrorTemplate(InvokeCallback invoke, TestCallback verify) { this.TestTemplate( invoke, (mock, service, asyncResult) => { mock.DomainClient.Error = new Exception(WebAuthenticationServiceTest.ErrorMessage); mock.DomainClient.RequestCallback(); Assert.IsFalse(mock.DomainClient.CancellationRequested, "Result should not be canceled."); }, verify, true); this.TestTemplate( invoke, (mock, service, asyncResult) => { mock.DomainClient.Error = new Exception(WebAuthenticationServiceTest.ErrorMessage); mock.DomainClient.RequestCallback(WebAuthenticationServiceTest.Delay); this.EnqueueConditional(() => asyncResult.IsCompleted); this.EnqueueCallback(() => { Assert.IsFalse(mock.DomainClient.CancellationRequested, "Result should not be canceled."); }); }, verify, false); this.EnqueueTestComplete(); }
internal void BeginInvoke(InvokeCallback callback) { BeginInvoke((Delegate)callback); }
private void TestTemplate(InvokeCallback invoke, TestCallback proceed, TestCallback verify, bool verifyInCallback) { AuthenticationDomainContext mock = new AuthenticationDomainContext(); MockWebAuthenticationService service = new MockWebAuthenticationService() ; service.DomainContext = mock; object state = new object(); bool testCompleted = false; AsyncCallback asyncCallback = ar => { Assert.IsNotNull(ar, "IAsyncResult should not be null."); Assert.AreEqual(state, ar.AsyncState, "States should be equal."); ExceptionHelper.ExpectException<NotSupportedException>( () => Assert.IsNull(ar.AsyncWaitHandle, "This property is not supported.")); Assert.IsFalse(ar.CompletedSynchronously, "IAsyncResult should not have completed synchronously."); Assert.IsTrue(ar.IsCompleted || mock.DomainClient.CancellationRequested, "IAsyncResult should be complete or cancelled."); verify(mock, service, ar); testCompleted = true; }; IAsyncResult asyncResult = invoke(mock, service, verifyInCallback ? asyncCallback : null, state); Assert.IsNotNull(asyncResult, "IAsyncResult should not be null."); Assert.AreEqual(state, asyncResult.AsyncState, "States should be equal."); ExceptionHelper.ExpectException<NotSupportedException>( () => Assert.IsNull(asyncResult.AsyncWaitHandle, "This property is not supported.")); Assert.IsFalse(asyncResult.CompletedSynchronously, "IAsyncResult should not have completed synchronously."); Assert.IsFalse(asyncResult.IsCompleted, "IAsyncResult should not be complete."); proceed(mock, service, asyncResult); if (!verifyInCallback) { this.EnqueueCallback(() => asyncCallback(asyncResult)); } this.EnqueueConditional(() => testCompleted); }