Skip to content
Bradley Grainger edited this page Jan 2, 2019 · 6 revisions

AsyncWorkItem.Current must only be used in methods that return IEnumerable<AsyncAction>.

The only safe location from which to access AsyncWorkItem.Current is from within a method that returns an IEnumerable<AsyncAction>. This analyzer flags any usages outside of that context.

Suggested Fixes

  • If the method in which AsyncWorkItem.Current occurs takes a parameter of type IWorkState, this parameter will be suggested.
  • A new parameter of type IWorkState on the method in which AsyncWorkItem.Current will always be suggested.
  • If the containing method takes a AsyncMethodContext context parameter, then context.WorkState is the correct fix. (This is not currently automatically suggested.)
  • If the current method is called by AsyncWorkItem.Start (which is rare), use the pattern described in #20.
Clone this wiki locally