C#中的VSIX visual studio扩展随机重置 [英] VSIX visual studio extension in C# gets reset randomly

查看:218
本文介绍了C#中的VSIX visual studio扩展随机重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VSIX VIsual studio扩展,它是一个工具窗口,有许多进度条和按钮。单击其中一个按钮可在后台启动5-8个工作线程。这将启动5-8进度条并显示线程的进度。 

偶尔我看到线程上的进度条随机重置;它几乎就像刷新ToolWindow一样,进度又恢复到默认状态。我不确定发生了什么,因为没有代码将进度条重置为默认状态。我的唯一解释是应用程序在某种程度上崩溃并在GUI上恢复。在重置之后,一些进程继续更新,好像没有任何事情从重置状态继续发生,好像什么也没发生(工作线程继续运行)。我无法弄清楚发生了什么。我该怎么解决这个问题?

您是否在GUI中随机重置的Visual Studio扩展中看到过这种问题?

我尝试了什么:

我查看了崩溃异常。暂无任何报告。

解决方案

这是一个未处理的异常。我应该使用不同的后台工作人员进行2次不同的按钮点击事件 - 我不小心使用了同一个按钮。我点击了两个按钮。



我在下面添加了错误检测和然后追踪错误。



 void workerBuild_RunWorkerCompleted(object sender,RunWorkerCompletedEventArgs e)
{
if(e.Error) == null)
{//像往常一样继续}
else
{//打印错误}
}

{


I have a VSIX VIsual studio extension which is a tool window and has many progress bars and buttons. Clicking one of the buttons starts 5-8 worker threads on the background..This starts the 5-8 progress bar and shows the progress of the thread.

Occasionally I see that the progress bar on the thread reset randomly; its almost like a refresh of the ToolWindow and the progress go back to default state. I am not sure what is happening because there is no code that resets the progress bar to default state. The only explanation that I have is the app is crashing and recovering on GUI somehow. After the reset, some of the progress keep updating as if nothing happened continuing on from the reset state as if nothing happened (the worker threads keep running). I am at a loss to figure out what is going on. How can i troubleshoot this?

Have you seen this kind of issue in a Visual Studio extension that you developed where the GUI resets randomly?

What I have tried:

I have looked at crash exceptions. Nothing to report yet.

解决方案

It was an exception that was unhandled. I should have used a different background worker for 2 different button click events- I accidentally used the same one and I was clicking both buttons.

I added below error detection and traced the error then.

void workerBuild_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error == null)
             {     //Proceed as usual}
            else
             {   //print out error}
          }

{


这篇关于C#中的VSIX visual studio扩展随机重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆