Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Webbrowser标记调用javascript函数正在停止我的UI线程_C#_Javascript_Multithreading_Windows Phone 8 - Fatal编程技术网

C# 使用Webbrowser标记调用javascript函数正在停止我的UI线程

C# 使用Webbrowser标记调用javascript函数正在停止我的UI线程,c#,javascript,multithreading,windows-phone-8,C#,Javascript,Multithreading,Windows Phone 8,我在WindowsPhone8中使用Webbrowser调用Javascript函数 browserControl.InvokeScript(funtionName, args); 这个javascipt函数在内部调用一个服务来获取数据,在我显示的javascript调用过程中 但我无法看到ProgressIndicator,因为javascript调用正在停止UI线程。 这个问题可能是因为Javascript函数和我的UI线程在同一个线程中运行。所以我尝试将Javascript函数调用移动

我在WindowsPhone8中使用Webbrowser调用Javascript函数

 browserControl.InvokeScript(funtionName, args);
这个javascipt函数在内部调用一个服务来获取数据,在我显示的javascript调用过程中

但我无法看到ProgressIndicator,因为javascript调用正在停止UI线程。

这个问题可能是因为Javascript函数和我的UI线程在同一个线程中运行。所以我尝试将Javascript函数调用移动到后台线程,但它没有说“无效的跨线程访问”

有人能建议我如何克服这个问题吗?

编辑:

我的进度指标代码:

public void ActivateProgressIndicator(this PhoneApplicationPage currentPage, string progressIndicatorText)
        {
            ProgressIndicator progressIndicator = new ProgressIndicator();
            progressIndicator.Text = progressIndicatorText;
            progressIndicator.IsVisible = true;
            progressIndicator.IsIndeterminate = true;
            SystemTray.SetProgressIndicator(currentPage, progressIndicator);
        }
我的JS函数正在内部调用WCF rest服务,此函数调用将花费30秒1分钟。我是后台线程的JS代码,如下所示:

ThreadPool.QueueUserWorkItem(o =>
            {
                WebBrowser browserControl = new WebBrowser();
                browserControl.IsScriptEnabled = true;
                browserControl.Navigate(new Uri("/WebAssets/Main.html", UriKind.RelativeOrAbsolute));

                browserControl.InvokeScript("RetrieveMultiple",
                                                         "http://some.service.net/",
                                                         "Plain",
                                                         "arg1",
                                                         "arg2",
                                                         "arg3");
            });

创建webbrowser控件时出现无效的跨线程错误。

您能添加一些相关代码吗?你的电话是怎么接通的?JavaScript函数在做什么?通常需要多长时间?您是如何尝试将JS调用移到后台的?是哪一行导致了无效的跨线程访问错误?感谢您的回复Thomas,我已经编辑了我的问题。您现在可以查看我的问题了吗。