KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm investigating Microsoft enterprise library (data application block) -- The samples sln. They have a sample of reading data asynchronously ( IAsync , although the new ver (6) also support async ). But Resharper( or visual studio- nevermind ) shows me : "Access to disposed closure" : (first i will show the image , so it will be clearer , then i'll paste the code ) code : /*1*/ [Description("Execute a command that retrieves data asynchronously")] /*2*/ static void ReadDataAsynchronously() /*3*/ { /*4*/ if (!SupportsAsync(asyncDB)) return; /*5*/ /*6*/ using(var doneWaitingEvent = new ManualResetEvent(false)) /*7*/ using(var readCompleteEvent = new ManualResetEvent(false)) /*8*/ { /*9*/ try /*10*/ { /*11*/ // Create command to execute stored procedure and add parameters /*12*/ DbCommand cmd = asyncDB.GetStoredProcCommand("ListOrdersSlowly"); /*13*/ asyncDB.AddInParameter(cmd, "state", DbType.String, "Colorado"); /*14*/ asyncDB.AddInParameter(cmd, "status", DbType.String, "DRAFT"); /*15*/ // Execute the query asynchronously specifying the command and the /*16*/ // expression to execute when the data access process completes. /*17*/ asyncDB.BeginExecuteReader(cmd, /*18*/ asyncResult = > /*19*/ { /*20*/ // Lambda expression executed when the data access completes. /*21*/ doneWaitingEvent.Set(); /*22*/ try /*23*/ { /*24*/ using(IDataReader reader = asyncDB.EndExecuteReader(asyncResult)) /*25*/ { /*26*/ Console.WriteLin
Tags (comma-separated)
Save Edits
Cancel