How to make DataObjectSelector SelectObjects method asynchronous?

In our VS Extension, we have few Custom Object Selector which inherits from Microsoft.VisualStudio.Data.Framework.DataObjectSelector
and we are overriding the SelectObjects
abstract method. Inside overridden SelectObjects
method, we are calling a time consuming method RetrieveObject()
to get the data and returning a DataReader
. And showing the data in VS Server Explorer hierarchy.
Because RetrieveObject()
is a time consuming operation, the UI thread is blocked and we are getting UI Delay warning from VS. Also, SelectObjects
is not async
method, so we are not able to make the RetrieveObject()
method async
and await
it inside SelectObjects
method.
Is there any way to invoke RetrieveObject
from SelectObjects
without blocking the UI thread?
internal class MyProviderObjectSelector : Microsoft.VisualStudio.Data.Framework.DataObjectSelector
{
protected override IVsDataReader SelectObjects(string typeName, object[] restrictions, string[] properties, object[] parameters)
{
base.Site.Lock();
try
{
ObjectDataTable = null;
QueryResult = null;
MyProviderViewDataReader viewDataReader = null;
RetrieveObjects(typeName, restrictions, properties, parameters, out viewDataReader); // Want to make RetrieveObjects method Async and Await for the result so that UI is not blocked
if (null == QueryResult)
{
// Mapping Code
return new AdoDotNetTableReader(ObjectDataTable);
}
else
{
if (viewDataReader != null)
return viewDataReader;
else
return GetViewDataReader();
}
}
finally
{
base.Site.Unlock();
}
}
// Other methods
}
We are using VS2022 17.3.2. The complete warning message is
Visutal Studio stopped responding for 7 seconds, Disabling the extension XXXXX for Visual Studio 2022 XX.X.X.X.X might help
Would you mind sharing some code snippets in order to investigate it further?
@AnnaXiu-MSFT , I have updated the question with the code snippet
Hello @AnnaXiu-MSFT , I understand that it has been a long time but we are still having this issue. I have looked into VS SDK documentation but looks like DataObjectSelector does not have any Async version of SelectObject abstract method. If we had a async SelectObject abstract method, we could have implemented the abstract method in our code base and await for any long running methods. Does VS SDK have any alternative of DataObjectSelector class that support async functionality?
Sign in to comment