i need to access to full properties, methods of GUI FORM from the process that are not the first one launched.
[MTAThread]
static void Main(string[] args)
{
//check if the app is already running
running = Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Length > 1;
Console.WriteLine("ALready running? " + running);
if (running) // not first process
{
MessageBox.Show("Application already running in background!!!");
closing = false;
// HERE I NEED TO ACCESS TO gui-form defined by the first process and call some methods, modify properties ...
}
else { //first process
if (!closing)// there are no process active
{
string selected = null;
if (args.Length == 1) //apertura da context menu
{
selected = args[0];
pathSend = selected;
}
Console.WriteLine("ALready running: opening " + pathSend);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//create userManagerUnit
umu = new UserManagerUnit();
//create a ManualResetEvent used from Server's Threads
// true -> server start work || false -> server stop work
mre = new ManualResetEvent(true);
// create Server istance
// active server
server = new Server();
serverThread = new Thread(server.EntryPoint) { Name = "serverThread" };
serverThread.IsBackground = true;
serverThread.Start();
//create new client
client = new Client();
// create gui istance
gui = new GUI(selected);
//run application
Application.Run(gui);
}
}
}
I tried with delegates, but i cannot delegate something that exist in an another process. My app is launched both from .exe/right click menu(on file/directory) So i can launch it N times, and each time i need to reload my gui with different parameters but i don't need to create N gui, just update the one created at first. Thanks