AsyncPackage
/ToolkitPackage
InitializeAsync
is called from the main thread
#527
Replies: 3 comments 1 reply
-
Might be related to https://learn.microsoft.com/en-us/visualstudio/extensibility/how-to-use-asyncpackage-to-load-vspackages-in-the-background?view=vs-2022#querying-services-from-asyncpackage... But how do I structure services that have slow async init but I don't want them to block the UI thread even when VS initializes the package synchronously... Ugh the wonders of legacy... |
Beta Was this translation helpful? Give feedback.
-
I want to only listen to actual addition or removal of projects to the solution, but |
Beta Was this translation helpful? Give feedback.
-
Segev, |
Beta Was this translation helpful? Give feedback.
-
My
AsyncPackage
/ToolkitPackage
is getting called from the main thread from some reason (Despite havingAllowsBackgroundLoading
and so on). Which then leads toGetServiceAsync
calls fromInitializeAsync
or commandsInitializeCompletedAsync
to a service that takes time to load although it uses async for everything, which leads to VS to hang, as it seems to block synchronously from the UI thread for this task chain to end. I think my initial package load is triggered from a command or tool window. I'm not sure what I'm doing wrong or how to correctly avoid the hang, as my commands do need this service for visibility status, and I'd rather not have the service do background init afterInitializeAsync
which will then require every user of it to await for that init to complete. Any ideas why this is happening and how should I handle this?Also
IsSolutionFullyLoaded
seems to be missing fromVS.Solutions
which as I understand is what I should check if the solution has fully loaded, and if not I can wait forAfterBackgroundSolutionLoadComplete
for it to finish loading, which kinda requires wrangling it yourself usingTaskCompletionSource
if I'm getting how it works correctly.Also the events for project open/close seem to be missing the added/removed flags so that I can use them to monitor when projects are added/removed, and
GetAllProjectsAsync
doesn't return anything when a folder is opened instead of a solution (The "Open a local folder" feature of VS).I just want to monitor the list of all currently opened projects and solution, but I think that flag is missing from the wrapper, I'm not sure if I'm listening for the correct event, and I'm not sure the wrapper handles "open folder" at all.
Any help is appreciated... Or is there a better place to ask questions?
VS isn't open source, so it's a bit hard to figure out how the whole init and lifecycle works to do this correctly...
Beta Was this translation helpful? Give feedback.
All reactions