Skip to content
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

Added UI thread information #514

Merged
merged 2 commits into from
Sep 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ If you can't find a solution below, please open an [issue](https://github.com/se
* [Using the Package Manager](#package-manager)
* [Versioning Convention](#versioning)
* [Viewing the Request Body](#request-body)
* [UI requests are failing](#ui-requests)

<a name="v2"></a>
## Continue Using the v2 API
Expand Down Expand Up @@ -119,3 +120,20 @@ You can do this right before you call `var response = await client.SendEmailAsyn
```csharp
Console.WriteLine(msg.Serialize());
```

<a name="ui-requests"></a>
## UI Requests are Failing

If your UI based requests are failing, it may be due to a little known issue where the UI only has a single thread. The answer here is to use `ContextAwait(false)` on the end of your request call, so that the thread does not reset back to request context and stays in capture context. Normally, async the request thread would "let go" of the capture context and reset to request context. With the UI, there is only a single thread, so you have to force the thread to switch to capture context, using `ContextAwait(false)`. For more information, please see a better summary that is linked to a longer article [in StackOverflow](https://stackoverflow.com/a/13494570).

In our example code, you would change:

```csharp
var response = await client.SendEmailAsync(msg);
```

to

```csharp
var response = await client.SendEmailAsync(msg).ConfigureAwait(false);
```