SharpDevelop icon indicating copy to clipboard operation
SharpDevelop copied to clipboard

Using Dispatcher when accessing the ItemsSource of the start page

Open mmgerald opened this issue 9 years ago • 4 comments

When using SDA the initialization of recent projects on start page, because after await another thread tried to access ItemSource

mmgerald avatar Apr 28 '16 13:04 mmgerald

I certify that I own, and have sufficient rights to contribute, all source code and related material intended to be compiled or integrated with the source code for the #develop open source product (the "Contribution"). My Contribution is licensed under the MIT License.

mmgerald avatar May 06 '16 08:05 mmgerald

Are there any news? Something missing? is it possible to merge the pull request?

mmgerald avatar Jun 01 '16 09:06 mmgerald

If BuildRecentProjectList is called on the UI thread then setting the ItemsSource should be called on the UI thread so you should not need to use the dispatcher. The Task.Run part will be run on another background thread. This task is awaited and so the code adding items to the list's ItemSource should execute on the UI thread.

mrward avatar Jun 01 '16 10:06 mrward

I agree that the code adding items to the list's ItemSource should execute on the UI thread. But the behavior is different when using SDA (Sharp Develop for Applications). After await, a MTA thread is returned form Thread Pool, that executes the code. In this case Sharp Develop is hosted in another process, therefore the Task Framework behave different.

It is reproducible when using samples\SdaUser, when including the StartPage Add-In.

mmgerald avatar Jun 02 '16 13:06 mmgerald