-
Notifications
You must be signed in to change notification settings - Fork 565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WCF Client (.net8.0 Win form Exe) Call will Hung if Sync Method is Invoked before Invoking any Async Method #5730
Comments
I believe this is the same as a previously reported issue that I haven't got to fixing yet. If it is the same, there's an easy workaround. In button1_Click, call |
@mconnew |
Are you able to provide a repro app? The only potential issue I'm aware of when it comes to UI apps we have explicit tests to validate that our methods to prevent it are working. Basically we only have an async implementation (earlier netcore days didn't have sync api's for anything IO) and sync calls are implemented using async and waiting on the result. The usual gotcha for this is when using a single threaded SynchonizationContext such as what WPF and WinForms uses, then the blocking Wait call on the Task prevents the async continuations from running. But we have logic which immediately jumps to a thread pool thread to prevent this. To see if this might be a variant I've missed, try doing this: var ctx = SynchronizationContext.Current;
SynchronizationContext.SetSynchronizationContext(null);
try
{
int result2 = client.StartCountPassCounter();
}
finally
{
SynchronizationContext.SetSynchronizationContext(ctx);
} If the problem goes away, then you are hitting a code path without that protection. If this "fixes" it, then I might be able to work out what's going on from a call stack from debugging. If it doesn't, then having a minimal repro app is the only way I'll be able to diagnose this. |
@mconnew , |
When it's blocked, could you get the call stack of that thread and post it here? I want to see which async method call isn't using a thread pool thread for continuation. |
I need the callstack of that main thread which has the WaitForCompletion call. The screenshot just shows me the last method on each thread. |
Repro:
Expected Results:
Both operations should return irrespective of the sequence of requests
Actual Results:
Scenario 1: If Sync call (button2_Click) is Invoked first, call never returns
Scenario 2: If Async call (button1_Click) is Invoked first and then Sync call (button_Click) is invoked, results are as expected
Scenario 3: Sync calls works fine provided async call was invoked at least once
No issue if client is running on .Net framework.
No issue if client is a console application on .Net 8.0
@mconnew , How to justify the above behavior with WCF client packages on .Net 8.0 ?
Your clarifications will help me to assess the feasibility of WCF client codebase migration to .Net 8.0
The text was updated successfully, but these errors were encountered: