I have a third-party API which requires thread affinity. I am using WCF in my service application to handle requests from a client which are then delegated to this API. Since WCF uses a thread pool to handle requests, I attempted to work around this…
I have MVC web app that uses EntityFramework context and it stores it in HttpContext.Current.Items. When HttpContext.Current isn't available then it uses CallContext.SetData to store data in current thread storage. HttpContext is used for web app…
My app works fine, but now I wanted to have custom startup, so I could catch any errors, add my logging from the start, etc.
So I used approach as shown in this answer What code controls the startup of a WPF application?
[STAThread]
public static…
I'm using WF to run activities and I would like to invoke the activity synchronously on the same thread as the calling thread. How would I do that using WorkflowInvoker.Invoke? The following is my code snippet:
public int…
Suppose a UI update takes quite a long time. As an example, this dummy label takes 1 second to change the text.
public class MyLabel : Label
{
public override string Text
{
get { return base.Text; }
set
{
…
I have a REST service that generates string messages with currencies and dates, so I need the right culture to be set up. Messages are produced in different steps that runs between asynchronous operations.
Web API will set the culture coming in the…
Problem Statement
We have tests that, at some point, cause a SynchronizationContext to be set on the current nunit thread. Mixing this with await causes a dead-lock to the best of my knowledge.
The issue is that we mix business logic with UI…
I have read quiet a few implementations of the EventAggregator (Messenger) to communicate between different ViewModels in WPF but I am having difficulties why we necessarily need to use a SynchronizationContext.
I understand that the…
I have a console application and my first line is in the Main method is:
TaskScheduler.FromCurrentSynchronizationContext();
but here my application crashes with the System.InvalidOperationException : Additional information: The current…
I have a custom framework where a host application runs an event loop and loads a guest application into a separate app-domain. The guest application has means to take advantage of the event loop via a provided API. I want to make the guest…
I have WPF application implemented with classic MVVM pattern, however View, Model and ViewModel are three different projects in my solution.
I have well-known implementation of AsyncObservebleCollection in my ViewModel
public class MyVM :…
As my English is not well, I explain my question simple and paste a code snippet here to describe the problem.
The problem is a multiple threading issue in our winForm application. I simple the logic as following code sample.
In the test code, there…
In his answer Stephen explained that when ConfigureAwait(false) is called the rest of the method will be executed on a thread pool thread unless the Task you're awaiting is already complete.
What is clear: If I use ConfigureAwait(false) everything…
In wpf I have two windows in separate threads.
From Window A' in Thread A I would like to start a Task in Tread B of Window B' and await the return value in Thread A.
It suppose it is possible but how?
Do you know an example perhaps?
My question was raised by one of the examples from this article:
private void button1_Click(object sender, EventArgs e) {
button1.Text = await Task.Run(async delegate
{
string data = await DownloadAsync();
return…