Skip to content

Commit 47c34e9

Browse files
committed
inital commit
1 parent 798c86b commit 47c34e9

36 files changed

+1223
-0
lines changed
10.5 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
5+
</startup>
6+
</configuration>
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
5+
</startup>
6+
</configuration>
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
5+
</startup>
6+
</configuration>
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
5+
</startup>
6+
</configuration>
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
5+
</startup>
6+
</configuration>
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{2688EB34-8274-4E8F-A0B7-074D51949EFB}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>Dashboard</RootNamespace>
10+
<AssemblyName>Dashboard</AssemblyName>
11+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<PlatformTarget>AnyCPU</PlatformTarget>
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>..\Build\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<PlatformTarget>AnyCPU</PlatformTarget>
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="System.Data.DataSetExtensions" />
39+
<Reference Include="Microsoft.CSharp" />
40+
<Reference Include="System.Data" />
41+
<Reference Include="System.Deployment" />
42+
<Reference Include="System.Drawing" />
43+
<Reference Include="System.Net.Http" />
44+
<Reference Include="System.Windows.Forms" />
45+
<Reference Include="System.Xml" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<Compile Include="DashboardForm.cs">
49+
<SubType>Form</SubType>
50+
</Compile>
51+
<Compile Include="DashboardForm.Designer.cs">
52+
<DependentUpon>DashboardForm.cs</DependentUpon>
53+
</Compile>
54+
<Compile Include="Program.cs" />
55+
<Compile Include="Properties\AssemblyInfo.cs" />
56+
<EmbeddedResource Include="DashboardForm.resx">
57+
<DependentUpon>DashboardForm.cs</DependentUpon>
58+
</EmbeddedResource>
59+
<EmbeddedResource Include="Properties\Resources.resx">
60+
<Generator>ResXFileCodeGenerator</Generator>
61+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
62+
<SubType>Designer</SubType>
63+
</EmbeddedResource>
64+
<Compile Include="Properties\Resources.Designer.cs">
65+
<AutoGen>True</AutoGen>
66+
<DependentUpon>Resources.resx</DependentUpon>
67+
</Compile>
68+
<None Include="Properties\Settings.settings">
69+
<Generator>SettingsSingleFileGenerator</Generator>
70+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
71+
</None>
72+
<Compile Include="Properties\Settings.Designer.cs">
73+
<AutoGen>True</AutoGen>
74+
<DependentUpon>Settings.settings</DependentUpon>
75+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
76+
</Compile>
77+
</ItemGroup>
78+
<ItemGroup>
79+
<None Include="App.config" />
80+
</ItemGroup>
81+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
82+
</Project>

MultiProcessExample/Dashboard/DashboardForm.Designer.cs

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.IO;
5+
using System.IO.Pipes;
6+
using System.Threading;
7+
using System.Windows.Forms;
8+
9+
namespace Dashboard
10+
{
11+
public partial class DashboardForm : Form
12+
{
13+
private List<Process> _processList;
14+
15+
public DashboardForm()
16+
{
17+
InitializeComponent();
18+
}
19+
20+
private void DashboardForm_Load(object sender, EventArgs e)
21+
{
22+
labelTime.Text = DateTime.Now.ToShortDateString();
23+
_processList = new List<Process>();
24+
}
25+
26+
private void buttonLaunch_Click(object sender, EventArgs e)
27+
{
28+
string[] modules = {@"Modules\ModuleA", @"Modules\ModuleB", @"Modules\ModuleC"};
29+
//string[] modules = { @"Modules\ModuleA" };
30+
31+
foreach (var p in modules)
32+
{
33+
var processStartInfo = new ProcessStartInfo();
34+
processStartInfo.FileName = p;
35+
processStartInfo.Arguments = Process.GetCurrentProcess().Id.ToString();
36+
var process = Process.Start(processStartInfo);
37+
_processList.Add(process);
38+
textBoxProcess.Text = textBoxProcess.Text + Environment.NewLine + p + " : " + process.Id;
39+
}
40+
41+
var RecieverThread = new Thread(StartServerListner);
42+
RecieverThread.Start();
43+
}
44+
45+
private void buttonTerminate_Click(object sender, EventArgs e)
46+
{
47+
foreach (var process in _processList)
48+
if(!process.HasExited)
49+
process.Kill();
50+
51+
_processList = new List<Process>();
52+
}
53+
54+
55+
private void StartServerListner()
56+
{
57+
using (var pipeStream = new NamedPipeServerStream("PipeTo" + Process.GetCurrentProcess().Id))
58+
{
59+
Console.WriteLine("[Server] Pipe Created, the current process ID is {0}",
60+
Process.GetCurrentProcess().Id);
61+
62+
//wait for a connection from another process
63+
pipeStream.WaitForConnection();
64+
Console.WriteLine("[Server] Pipe connection established");
65+
66+
using (var sr = new StreamReader(pipeStream))
67+
{
68+
string message;
69+
//wait for message to arrive from the pipe, when message arrive print date/time and the message to the console.
70+
while ((message = sr.ReadLine()) != null)
71+
Console.WriteLine("{0}: {1}", DateTime.Now, message);
72+
}
73+
}
74+
Console.WriteLine("Connection lost");
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)