Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Asynchronous_Programming</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,38 @@ public class Multithreading
{
public void FirstMethod()
{
Console.WriteLine("First Multithreading Method on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("First Multithreading Method on Thread with Id: " + Environment.CurrentManagedThreadId);
Thread.Sleep(1000);
Console.WriteLine("First Multithreading Method Continuation on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("First Multithreading Method Continuation on Thread with Id: " + Environment.CurrentManagedThreadId);
}

public void SecondMethod()
{
Console.WriteLine("Second Multithreading Method on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("Second Multithreading Method on Thread with Id: " + Environment.CurrentManagedThreadId);
Thread.Sleep(1000);
Console.WriteLine("Second Multithreading Method Continuation on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("Second Multithreading Method Continuation on Thread with Id: " + Environment.CurrentManagedThreadId);
}

public void ThirdMethod()
{
Console.WriteLine("Third Multithreading Method on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("Third Multithreading Method on Thread with Id: " + Environment.CurrentManagedThreadId);
Thread.Sleep(1000);
Console.WriteLine("Third Multithreading Method Continuation on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("Third Multithreading Method Continuation on Thread with Id: " + Environment.CurrentManagedThreadId);
}

public void ExecuteMultithreading()
{
Thread t1 = new Thread(new ThreadStart(FirstMethod));
Thread t2 = new Thread(new ThreadStart(SecondMethod));
Thread t3 = new Thread(new ThreadStart(ThirdMethod));
Thread t1 = new Thread(FirstMethod);
Thread t2 = new Thread(SecondMethod);
Thread t3 = new Thread(ThirdMethod);

t1.Start();
t2.Start();
t3.Start();

t1.Join();
t2.Join();
t3.Join();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ public class Program
{
public static async Task FirstAsync()
{
Console.WriteLine("First Async Method on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("First Async Method on Thread with Id: " + Environment.CurrentManagedThreadId);
await Task.Delay(1000);
Console.WriteLine("First Async Method Continuation on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("First Async Method Continuation on Thread with Id: " + Environment.CurrentManagedThreadId);
}

public static async Task SecondAsync()
{
Console.WriteLine("Second Async Method on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("Second Async Method on Thread with Id: " + Environment.CurrentManagedThreadId);
await Task.Delay(1000);
Console.WriteLine("Second Async Method Continuation on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("Second Async Method Continuation on Thread with Id: " + Environment.CurrentManagedThreadId);
}

public static async Task ThirdAsync()
{
Console.WriteLine("Third Async Method on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("Third Async Method on Thread with Id: " + Environment.CurrentManagedThreadId);
await Task.Delay(1000);
Console.WriteLine("Third Async Method Continuation on Thread with Id: " + Thread.CurrentThread.ManagedThreadId);
Console.WriteLine("Third Async Method Continuation on Thread with Id: " + Environment.CurrentManagedThreadId);
}

public static async Task ExecuteAsyncFunctions()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Asynchronous_Programming_Tests</RootNamespace>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.10.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.10.4" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>

Expand Down
Loading