I have two WPF Applications, for example, one is A_wpf application, the others is B_wpf application.
There are one Button on each application. I want to Button in A_wpf application to Start up B_wpf application and show B_wpf with Maximized. I want to Button in B_wpf application to do the same thing as A_wpf Application do.
Could anyone give me any advices please?
You can use Process.Start(path_to_exe):
using System.Diagnostics;
//...
Process.Start(path_to_exe);
Now if you want to avoid opening another instance if the target application is already running, you coud use Mutex for that.
Related
I am have two different WPF applications running differently. now my requirement is to merge these application. Now Both application are WPF application. So I need to call Second application from the First Application So bascially I have created Two windows and I am initializing the Window2 from Window1 on a button click. Now the problem assuming that I have used the same resource files for both application.
What will happen if I close my First WPF application will the Second application will also get closed?
What should be the best approach in these situations?
If my main application window closes then the resource will also go out of scope and how should i ensure my appliction works correctly?
At the Application level you can set the ShutdownMode property to define the condition that will make the application terminate.
If the second application cannot run without the first one for some reason, as you suggest in your post, you could set this property to OnMainWindowClose. This way, if the first one is closed, the full application will stop
Spawn a new process on button click, that opens AppB. But that will keep both apps separate from each other, so no data sharing either. If you want to share data and code, add each page from AppB manually to AppA just like adding a third party control.
I need to write a very small application which writes some system data to a file and then exits. I could do this in a console application but I have no need or desire for a console window to appear during this process.
I would normally use a Windows Forms application with no forms, execute the code in the Main method and then allow the application to exit, however, this time I couldn't help but wonder if this is the best way to do it and whether you could do it with a WPF application instead, what the differences are and whether or not once you've remove any forms/windows and unnecessary reference, it matters or not.
WPF and WinForms are two different libraries that show UIs.
If you never show a UI, you aren't using either of them.
You should start with a WinForms project (WPF projects set extra project metadata that you don't want), then delete the reference to System.Windows.Forms.dll.
Alternatively, start with a console project, then change the Output type to Windows Application.
Windows Forms with no window or console app with the type changes to windows application will give you the same result which is a simple app with Main() method and now windows.
WCF will only make sense if you actually want to display something as you're not going to use any of its features in your case.
I've got a console application and I want to run it from another application. But when I invoke it from code--to call program I use ActiveXObject--it shows the console. How do I get it to not show the console? I mean, the program works but console is shown.
If you make the application a Windows Application instead of a Console Application it will not show or open (or use) a Console. Your code can stay the same - and the application will still function (without ever creating a Form or Window).
That being said, if you control the "other" application, you may want to consider making a class library instead of a separate Application. This would allow you to just include and run code within the library without starting a separate process.
You can create it as a Windows Forms application with a hidden window. That's just one possibility like Reed Copsey pointed out, i used it once because i needed to process some specific Window Messages.
I need to develop an application in Winform C# and trying to find out suitable design pattern for this application.
Basically, My application Interacts with couple of Exes and output is monitored and based on the output, user will click button to trigger another console application (as shown in fig).
Right now, I have written separate class for every console application with which my application is interacting.
What are best ways to solve this problem (using Design Patterns).
Thank you,
Harsha
Are the Console App from 3d?
If not, You are able to create another Project(DLL) with the methods of that apps, and use it on your Winforms app.
I'm having a bit of a trouble trying to create a multi window'ed console application. Currently, my application's main console window is used to collect user input and display output.
Much of this output comes from a separate thread, as live data comes in. I was wondering if there is a way for me to separate my application into two windows, where the second window was either a console window or even any other kind of window that could display the text of the incoming strings... In particular, the main console window would be where the user input commands etc, and the second window displayed what the system was currently working on. This second window could be entirely readonly.
Any suggestions would be greatly appreciated! I would post code, but I don't really have anything relevant (that I can think of) to post....
This will be hard to do.
Here is answer for similar question: Can you have multiple .net Consoles (as in Console.Writeline)
If you really want to do it, you can find logic here: http://www.codeproject.com/KB/cpp/MultipleConsoles.aspx
Maby better approach will be to start another process (console app) and communicate between them thru IPC ( Interprocess communication ) - like named pipes .
More about IPC you can find: http://www.infoq.com/news/2008/01/wcf-comm-options
It is probably easier to just pop-up a Windows Form with a TextBox containing the data you wish to show. You can simply start a new thread and call Form.ShowDialog() to get the form to show.