Comments (5)
is the
BaseToolWindow<T>.Initialize
API meant to be thread safe?
🤔 The tool windows are registered against the ToolkitPackage
and inside the package they're not stored in static fields or anything like that, so no chance of two different packages registering tool windows into the same collection. Under normal circumstances, I would expect that the Initialize
methods of two different tool windows would be called sequentially, and that would be done before switching to the main thread (my understanding is that you should try to do as much work as possible before switching to the main thread). For example:
MyFirstToolWindow.Initialize();
MySecondToolWindow.Initialize();
await JoinableTaskFactory.SwitchToMainThreadAsync();
So with that in mind, I would say that no, it's not meant to be thread-safe.
from community.visualstudio.toolkit.
@bluetarpmedia @reduckted what if it used a ConcurrentList
or similar? Would that stop a potential race condition?
from community.visualstudio.toolkit.
Yeah, a lock around any usage of _toolWindowProviders
would solve it, or another option would be to enforce that the methods that read/write that list all run on the same thread (e.g. the UI thread, by calling ThreadHelper.ThrowIfNotOnUIThread
at the start of AddToolWindow
, GetToolWindowProvider
, or GetAsyncToolWindowFactory
).
But I'm not sure whether this is a problem that needs to be solved because to get a race condition I think the user is going to need to do something a bit odd.
It reminds me of the saying about protecting against Murphy (accidental misuse) vs Machiavelli (deliberate abuse). I think, yes, it should try and protect against accidental misuse of the API, but it's not worth trying to protect against deliberately silly code that's attempting to break it. So that poses the question: is the BaseToolWindow<T>.Initialize
API meant to be thread safe?
from community.visualstudio.toolkit.
protecting against Murphy (accidental misuse) vs Machiavelli (deliberate abuse)
I hadn't heard that expression. I like it!
from community.visualstudio.toolkit.
I'm closing this as the intention is for Initialize to not be thread-safe.
from community.visualstudio.toolkit.
Related Issues (20)
- Visual Studio 17.6 uses Newtonsoft.Json 13.0.3
- Source generator goes in infinite loop for .xml file extension. HOT 3
- Which control is used by Debugger Locals window and Watch window HOT 1
- Change name of the generated file using a visual studio extension.
- PhysicalFile.FromFileAsync does not return projects HOT 1
- Visual Studio extension template project for .NET core/6.0. HOT 2
- Replacement for the WPF Listview? HOT 3
- How does the Vsix extension prevent Visual Studio from capturing keyboard events
- Cannot set global keybinding HOT 1
- Unable to add custom command to project's context menu in Visual Studio 2022 using VSIX Community toolkit HOT 1
- Some tool windows are broken if using VS.Events.WindowEvents.ActiveFrameChanged HOT 2
- Template broken in VS2022 HOT 1
- GetSelectionAsync does not return non-code type document references.
- Get the users current theme programatically (VS2019-2022) HOT 5
- Extension method should be on ToolkitPackage not AsyncPackage HOT 1
- Error when removing unassigned files from solution folders in VS Experimental Instance with Demo Extension
- Sticky Scroll ?
- Community Pages not working HOT 1
- Strange behavior with Dynamic Visbility HOT 2
- Where is `ToolkitToolWindowPane`? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from community.visualstudio.toolkit.