Skip to content

Instantly share code, notes, and snippets.

@way2datta
Last active July 8, 2021 06:26
Show Gist options
  • Save way2datta/f9ced8c13eccbcb03f49d50b06f73647 to your computer and use it in GitHub Desktop.
Save way2datta/f9ced8c13eccbcb03f49d50b06f73647 to your computer and use it in GitHub Desktop.
This program will be used to show "Running Many Programs At Once"
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security;
using System.Threading;
internal class Program
{
[DllImport("Kernel32.dll"), SuppressUnmanagedCodeSecurity]
public static extern int GetCurrentProcessorNumber();
private static void Main()
{
var currentProcess = Process.GetCurrentProcess();
Console.WriteLine($"Please enter any string for process {currentProcess.Id} which is executed by {GetCurrentProcessorNumber()}: ");
var readline = Console.ReadLine();
var i = 0;
while (i++ < 12)
{
Console.WriteLine($"For process {currentProcess.Id} which is executed by {GetCurrentProcessorNumber()}, you have entered: {readline}");
Thread.Sleep(1000);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment