This file contains hidden or 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
namespace MultiThreadingExamples | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Priting Even numbers using Parallel.For"); | |
Parallel.For(0, 10, i => | |
{ | |
if (i % 2 == 0) |
This file contains hidden or 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
namespace MultiThreadingExamples | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Priting Even numbers using Parallel.For"); | |
Parallel.For(0, 10, i => | |
{ | |
if (i % 2 == 0) |
This file contains hidden or 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
namespace MultiThreadingExamples | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string objectText = DownloadContentFromApi(1).Result; | |
Console.WriteLine(objectText); | |
Console.ReadLine(); |
This file contains hidden or 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
namespace MultiThreadingExamples | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var aLotOfNumbers = Enumerable.Range(0, 100); | |
var parallelEvenNumbers = aLotOfNumbers | |
.AsParallel() |
This file contains hidden or 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
namespace MultiThreadingExamples | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var aLotOfNumbers = Enumerable.Range(0, 100); | |
var parallelEvenNumbers = aLotOfNumbers |
This file contains hidden or 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
namespace MultiThreadingExamples | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var anIncrediblyBigSet = Enumerable.Range(0, 10); | |
var parallelEvenNumbers = anIncrediblyBigSet | |
.AsParallel() |
This file contains hidden or 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
namespace manage_multithreading | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int theAlmightyZero = 0; | |
Task newAmazingTask = Task.Run(() => | |
{ |
This file contains hidden or 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
namespace manage_multithreading | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int theAlmightyZero = 0; | |
object _lockTheSavior = new object(); | |
Task newAmazingTask = Task.Run(() => |
This file contains hidden or 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
namespace manage_multithreading | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
object _lockSaviorOne = new object(); | |
object _lockSaviorTwo = new object(); | |
Task leTask = Task.Run(() => |
This file contains hidden or 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
private static int _theFlag; | |
private static int _theValue; | |
public static void TheFirstThread() | |
{ | |
_theValue = 10; | |
_theFlag = 1; | |
} | |
public static void TheSecondThread() | |
{ |