Question

Outline: I have two Projects. One project is Primary and is used GUI and primary processing of information. The Second Project is Secondary to the first and completes tasks over a span in time.

Start Secondary Project:

Thread thread = new Thread(() =>
{
main.MainForm = new MainForm();
main.MainForm.FormClosed += new FormClosedEventHandler(MainForm_FormClosed);
main.MainForm.ShowMainForm();
Application.Run();
});
thread.SetApartmentState(ApartmentState.MTA);
thread.Start();

References: I have added a Reference to the Secondary Project in the primary project so I can access it.

My Issue: I need a way report progress and any possible issues that may arise back to the primary Project. When I start the Secondary Project in another Thread, I seem to loose a lot of access to the Secondary Project.

I have tried to reference:

main.MainForm...

This seems to be a little problematic.

I wonder if there is a way to manage my code, specifically progress and errors through some sort of simple event system?

Any help and or ideas on best practices in this situation would be much appreciated.

Was it helpful?

Solution

This answer belongs to: Aleksandar Toplek - See notes above.

• Anonymous pipes.

Anonymous pipes provide interprocess communication on a local computer. Anonymous pipes require less overhead than named pipes but offer limited services. Anonymous pipes are one-way and cannot be used over a network. They support only a single server instance. Anonymous pipes are useful for communication between threads, or between parent and child processes where the pipe handles can be easily passed to the child process when it is created.

• Named pipes.

Named pipes provide interprocess communication between a pipe server and one or more pipe clients. Named pipes can be one-way or duplex. They support message-based communication and allow multiple clients to connect simultaneously to the server process using the same pipe name. Named pipes also support impersonation, which enables connecting processes to use their own permissions on remote servers.

Pipe Operations in the .NET Framework

http://msdn.microsoft.com/en-us/library/bb762927(v=vs.110).aspx

How to: Use Anonymous Pipes for Local Interprocess Communication

http://msdn.microsoft.com/en-us/library/bb546102.aspx

AnonymousPipeServerStream Class

http://msdn.microsoft.com/en-us/library/system.io.pipes.anonymouspipeserverstream(v=vs.110).aspx

AnonymousPipeClientStream Class

http://msdn.microsoft.com/en-us/library/system.io.pipes.anonymouspipeclientstream(v=vs.110).aspx

An EXCELLENT Example here: C# Async Named Pipes

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top