![resharper 9 false errors resharper 9 false errors](http://slideplayer.com/9/2539662/big_thumb.jpg)
You can configure whether you want to exclude asynchronous methods that don't return a value from this rule.
RESHARPER 9 FALSE ERRORS CODE
For more information, see Code quality rule configuration options. You can configure all of these options for just this rule, for all rules, or for all rules in this category ( Reliability). Use the following options to configure which parts of your codebase to run this rule on.
RESHARPER 9 FALSE ERRORS HOW TO
For more information, see How to suppress code analysis warnings. There are various ways to suppress a code analysis warning, including disabling the rule for the project, using a preprocessor directive to disable it for a specific line of code, or by applying the SuppressMessageAttribute attribute. As another example, when writing code in an ASP.NET Core application, by default there is no SynchronizationContext or TaskScheduler, for which reason a ConfigureAwait wouldn't actually change any behavior. For example, when writing code in a button click event handler in a WinForms or WPF application, in general the continuation from an await should run on the UI thread, and thus the default behavior of scheduling the continuation back to the originating context is desirable. You can suppress this warning in any situation where either the continuation should be scheduled back to the original context or where there is no such context in place. It is generally appropriate to suppress the warning entirely for projects that represent application code rather than library code in fact, running this analyzer on application code (for example, button click event handlers in a WinForms or WPF project) is likely to lead to the wrong actions being taken. This warning is intended for libraries, where the code may be executed in arbitrary environments and where code shouldn't make assumptions about the environment or how the caller of the method may be invoking or waiting on it. To fix the violation, call ConfigureAwait on the awaited Task: public async Task Execute() The following code snippet generates the warning: public async Task Execute() Passing false is a good option for app-independent libraries. By explicitly calling this method, you're letting readers know you intentionally want to perform the continuation on the original synchronization context.Ĭall ConfigureAwait(false) on the task to schedule continuations to the thread pool, thereby avoiding a deadlock on the UI thread. You can pass either true or false for the continueOnCapturedContext parameter.Ĭalling ConfigureAwait(true) on the task has the same behavior as not explicitly calling ConfigureAwait. To fix violations, call ConfigureAwait on the awaited Task. Consider calling Task.ConfigureAwait(Boolean) to signal your intention for continuation. This behavior can be costly in terms of performance and can result in a deadlock on the UI thread.
![resharper 9 false errors resharper 9 false errors](http://slideplayer.com/slide/15283084/92/images/9/Warnings%2C+suggestions+and+hints.jpg)
When an asynchronous method awaits a Task directly, continuation usually occurs in the same thread that created the task, depending on the async context. An asynchronous method awaits a Task directly.