public void TestJSCallback(IJavascriptCallback javascriptCallback)
 {
     using (javascriptCallback)
     {
         javascriptCallback.ExecuteAsync("Hello from winforms and C# land!");
     }
 }
Пример #2
0
        public void TestCallback(IJavascriptCallback javascriptCallback)
        {
            const int taskDelay = 1500;

            Task.Run(async () =>
            {
                await Task.Delay(taskDelay);

                using (javascriptCallback)
                {
                    await javascriptCallback.ExecuteAsync("This callback from C# was delayed " + taskDelay + "ms");
                }
            });
        }
        public void TestCallbackStruct(IJavascriptCallback javascriptCallback)
        {
            const int taskDelay = 500;

            Task.Run(async () =>
            {
                await Task.Delay(taskDelay);

                using (javascriptCallback)
                {
                    CallbackResponseStruct response = new CallbackResponseStruct("Test");
                    await javascriptCallback.ExecuteAsync(response);
                }
            });
        }
Пример #4
0
        public void TestCallback(IJavascriptCallback javascriptCallback)
        {
            const int taskDelay = 1500;

            Task.Run(async () =>
            {
                await Task.Delay(taskDelay);

                using (javascriptCallback)
                {
                    //NOTE: Classes are not supported, simple structs are
                    var response = new CallbackResponseStruct("This callback from C# was delayed " + taskDelay + "ms");
                    await javascriptCallback.ExecuteAsync(response);
                }
            });
        }
        public void TestCallbackClass(IJavascriptCallback javascriptCallback)
        {
            const int taskDelay = 500;

            Task.Run(async () =>
            {
                await Task.Delay(taskDelay);

                using (javascriptCallback)
                {
                    CallbackResponseClass response = new CallbackResponseClass("Test");
                    try
                    {
                        javascriptCallback.ExecuteAsync(response);
                    }
                    catch (Exception ex)
                    {
                        javascriptCallback.ExecuteAsync(string.Format("Error: {0}", ex.Message));
                    }
                }
            });
        }
        public void TestCallbackException(IJavascriptCallback errorCallback, IJavascriptCallback errorCallbackResult)
        {
            const int taskDelay = 500;

            Task.Run(async () =>
            {
                await Task.Delay(taskDelay);

                using (errorCallback)
                {
                    JavascriptResponse result = await errorCallback.ExecuteAsync("This callback from C# was delayed " + taskDelay + "ms");
                    string resultMessage;
                    if (result.Success)
                    {
                        resultMessage = "Fatal: No Exception thrown in error callback";
                    }
                    else
                    {
                        resultMessage = "Exception Thrown: " + result.Message;
                    }
                    await errorCallbackResult.ExecuteAsync(resultMessage);
                }
            });
        }