I have a method that performs some unit of work, and can optionally be spawned within a new thread or synchronously, dependant on a boolean parameter.
What's the cleanest or most standard way to implement this strategy?
To figuratively illustrate this example:
private static void MyMethod(Boolean synchronous) {
if (synchronous) {
SomeMethod();
} else {
new Thread(() => {
SomeMethod();
}.Start();
}
}
Aucun commentaire:
Enregistrer un commentaire