Question

I have a WPF application, and i need to launch some actions (and receive return values) starting from another console application.

I encountered many problems so i don t know exactly how to proceed:

1- I tried to use command lines with arguments(it worked to launch the wpf application), but i couldn't receive return Values, because they are only returned on application shutdown. Also it doesn't fit my need since some actions must be called while the wpf app is still running.

2- I thought abt developping a small dll to communicate between Console and WPF application, but i don't know what technology would be light, efficient and fit my needs.

Has any one achieved similar task in the past? If so, how did you go about it?

Thanks,

Was it helpful?

Solution

What you are looking for is usually termed 'Inter-process communication'. Named pipes are a type of IPC and can be used in .net. This guide should get you started.

OTHER TIPS

You could use WCF technology to achieve this. Define contract in you wpf application, where you should set your action logic - methods, by which you want to manage your application. If it is single sided, use netTcpBinding and create endpoint in your WPF application - it is a listener from the commands from outeside. Then in your your console application add proxy class of your wpf application, using svcutil. This will allow you to send your commands. If you do everything right - this should work. I suppose you have 1 wpf application and 1 console application.

You may launch your wpf app and then use:

  1. Named Pipes - the simplest way but you must create a protocol of interaction between apps. You may transfer serialized objects for example. (example);
  2. Shared files;
  3. WCF - most powerfull and complex technology.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top