<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : VS 2012 Async</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : Community Forum : VS 2012 Async</description>
  <pubDate>Fri, 10 Apr 2026 19:11:21 -700</pubDate>
  <lastBuildDate>Fri, 21 Sep 2012 06:19:07 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=3639</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>VS 2012 Async : That works great, thanks. This...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3639&amp;PID=14493#14493</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=449" rel="nofollow">smi-mark</a><br /><strong>Subject:</strong> 3639<br /><strong>Posted:</strong> 21-Sep-2012 at 6:19am<br /><br />That works great, thanks. This really helps clean up and simplify the code!]]>
   </description>
   <pubDate>Fri, 21 Sep 2012 06:19:07 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3639&amp;PID=14493#14493</guid>
  </item> 
  <item>
   <title>VS 2012 Async : Also, here is a useful error handler...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3639&amp;PID=14481#14481</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3639<br /><strong>Posted:</strong> 20-Sep-2012 at 9:46am<br /><br />Also, here is a useful error handler that I'm using in TempHire v2.&nbsp;<div><br></div><div><div>&nbsp; &nbsp; public class ErrorHandler : IErrorHandler</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; private readonly IDialogManager _dialogManager;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &#091;ImportingConstructor&#093;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public ErrorHandler(IDialogManager dialogManager)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dialogManager = dialogManager;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; #region IErrorHandler Members</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; public void HandleError(Exception ex)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string customMessage = null;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ex is EntityManagerSaveException &amp;&amp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ((EntityManagerSaveException) ex).FailureType == PersistenceFailure.Concurrency)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; customMessage = "Another user has previously saved the current record.";</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (ex is TaskCanceledException)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Log and ignore</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LogFns.DebugWriteLine(ex.Message);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _dialogManager.ShowMessageAsync(customMessage ?? ex.Message, DialogButtons.Ok);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; #endregion</div><div>&nbsp; &nbsp; }</div></div>]]>
   </description>
   <pubDate>Thu, 20 Sep 2012 09:46:56 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3639&amp;PID=14481#14481</guid>
  </item> 
  <item>
   <title>VS 2012 Async : With async/await you write code...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3639&amp;PID=14480#14480</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1005" rel="nofollow">mgood</a><br /><strong>Subject:</strong> 3639<br /><strong>Posted:</strong> 20-Sep-2012 at 9:42am<br /><br />With async/await you write code very much like you would write synchronous code. Error handling is done using try/catch. The following is an example. In this case I'm just rethrowing the exception and handle it in the UnhandledException handler.<div><br></div><div><div>&nbsp; &nbsp; &nbsp; &nbsp; public async void Delete()</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; await _dialogManager.ShowMessageAsync(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string.Format("Are you sure you want to delete {0}?", ActiveStaffingResource.FullName),</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DialogResult.Yes, DialogResult.No, DialogButtons.YesNo);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; using (ActiveDetail.Busy.GetTicket())</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ActiveUnitOfWork.StaffingResources.Delete(ActiveStaffingResource);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; await ActiveUnitOfWork.CommitAsync();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ActiveItem.TryClose();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; catch (TaskCanceledException)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ActiveUnitOfWork.Rollback();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; catch (Exception)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ActiveUnitOfWork.Rollback();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div></div>]]>
   </description>
   <pubDate>Thu, 20 Sep 2012 09:42:36 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3639&amp;PID=14480#14480</guid>
  </item> 
  <item>
   <title>VS 2012 Async :   Just curious as to what the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3639&amp;PID=14479#14479</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=449" rel="nofollow">smi-mark</a><br /><strong>Subject:</strong> 3639<br /><strong>Posted:</strong> 20-Sep-2012 at 8:53am<br /><br />Just curious as to what the best practices are now for writing async code.<br><br>Previously we have had code such as:<br><br><table width="99%"><tr><td class="BBquote"><br>&nbsp; Busy.AddWatch();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Repository.SaveAsync(() =&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Success Logic Here<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }, ErrorHandler.HandleError)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .WhenCompleted(e =&gt; Busy.RemoveWatch());<br></td></tr></table><br><br>Now we have code like<br><br><table width="99%"><tr><td class="BBquote"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Busy.AddWatch();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var op =&nbsp; Repository.SaveAsync().ContinueWith(t =&gt; Busy.RemoveWatch());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; op.HandleError(ErrorHandler.HandleError);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; await op;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Success Logic Here<br></td></tr></table><br><br>Is this the best way? I have seen people wrapping try handlers around await calls but that seems messy.<br><br>I see that HandleError doesn't return a Task so you can't await it. Is that by design?<br><span style="font-size:10px"><br /><br />Edited by smi-mark - 20-Sep-2012 at 9:11am</span>]]>
   </description>
   <pubDate>Thu, 20 Sep 2012 08:53:35 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3639&amp;PID=14479#14479</guid>
  </item> 
 </channel>
</rss>