Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Learning Parallel.Invoke in C#
SUBMITTED BY:
emmek
DATE:
March 20, 2023, 12:28 a.m.
FORMAT:
C#
SIZE:
911 Bytes
Raw
Download
Tweet
HITS:
79
Go to comments
Report
//CREDIT AND THANKS TO: learn.microsoft.com
static
void
Main
()
{
try
{
Parallel
.
Invoke
(
LaPrimaAzione
,
()
=>
{
Console
.
WriteLine
(
"Method=2 - Thread={0}"
,
Thread
.
CurrentThread
.
ManagedThreadId
);
},
delegate
()
{
Console
.
WriteLine
(
"Method=3 - Thread={0}"
,
Thread
.
CurrentThread
.
ManagedThreadId
);
}
);
}
catch
(
AggregateException
e
)
{
Console
.
WriteLine
(
"ERROR: {0} \n"
,
e
.
InnerException
.
ToString
());
}
}
static
void
LaPrimaAzione
()
{
Console
.
WriteLine
(
"Method=1 - Thread={0}"
,
Thread
.
CurrentThread
.
ManagedThreadId
);
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus