Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Need a way to use OidcClient from a worker thread #122

@jzkirtley

Description

@jzkirtley

I am currently attempting to use OIDC authentication in a legacy Winforms app. The login process is extremely arcane (it can happen in the background or through user action, and authentication can take a number of different forms). Much of the login code predates the async/await model in .net, and involves worker threads that occasionally post information back to the main UI thread (for example, status updates)

Because of this, I need to be able to call OidcClient.Login Synchronously. However, attempting to simply force synchronization don't work. Specifically:

            loginResult = oidcClient.LoginAsync(loginRequest).Result;

throws an exception:
InnerException = {"Cannot change thread mode after it is set. (Exception from HRESULT: 0x80010106 (RPC_E_CHANGED_MODE))"}

I believe I can generate a simple test case if necessary, assuming there's a good generic OAuth server running somewhere I could use as a test bed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions