"Visual Studio stopped responding for 12 seconds,uninstalling extension might help" getting this message on installing VSIX and on opening the project

64 views Asked by At

When trying to add existing/New item, getting error message like "Cannot access to disposed object". To resolve that making the method to run asynchronously and it got resolved, but due to that getting some delay in extension after opening the project.In this method first getting "Cannot access to disposed object" error.

 private void ProjectItemsEvents_AfterAddProjectItems ()
 {
    
 }

After making it to asynchronous method, getting delay in extension.

 private async void asynchronous ()
 {
    await System.Threading.Tasks.Task.Run(() => ProjectItemsEvents_AfterAddProjectItems();
 }

Need to know, how to remove the delay causing by the asynchronous method

1

There are 1 answers

0
matt sharp On

You're running the action in another thread. The app then thinks its finished and disposes what the thread needs - Its not about a delay.

You could do:

private async Task asynchronous ()
{
    ProjectItemsEvents_AfterAddProjectItems();
}

This will however be marked as a warning since it doesn't use await.

If there is no async stuff in "ProjectItemsEvents_AfterAddProjectItems"

private async Task asynchronous ()
{
    await Task.FromResult(ProjectItemsEvents_AfterAddProjectItems());
}