Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[corlib] Mark all promise-style task exceptions observed. Fixes #17015
- Loading branch information
1 parent
8c73578
commit b95d8a6
Showing
8 changed files
with
181 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
class X | ||
{ | ||
static bool unobserved; | ||
|
||
public static int Main () | ||
{ | ||
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; | ||
try { | ||
Test ().Wait (); | ||
|
||
GC.Collect (); | ||
GC.WaitForPendingFinalizers (); | ||
if (unobserved) | ||
return 1; | ||
|
||
return 0; | ||
} finally { | ||
TaskScheduler.UnobservedTaskException -= TaskScheduler_UnobservedTaskException; | ||
} | ||
} | ||
|
||
static void TaskScheduler_UnobservedTaskException (object sender, UnobservedTaskExceptionEventArgs e) | ||
{ | ||
unobserved = true; | ||
Console.WriteLine ("unobserved"); | ||
} | ||
|
||
static async Task Test () | ||
{ | ||
try { | ||
await ThrowAsync (); | ||
} catch { | ||
} | ||
} | ||
|
||
static async Task ThrowAsync() | ||
{ | ||
await Task.Delay (5); | ||
|
||
throw new Exception ("boom"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters