1

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,

3 Answers3

0

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.

Alex
  • 8,827
  • 3
  • 42
  • 58
  • I am trying to use a WCF service on my WPF application, but i am wondering if it will cause performance problems if my WPF application will keep listening to commands from outside. Thanks – user1948874 Oct 16 '13 at 13:42
  • @user1948874 The performance hit would not be felt to the end user. It is just another opened port, which is listened with a separate thread. You should not warn about this. – Alex Oct 16 '13 at 14:05
0

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.
Community
  • 1
  • 1
Deffiss
  • 1,136
  • 7
  • 12
0

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.

ChrisO
  • 5,068
  • 1
  • 34
  • 47
  • I heard abt it but never used it before. But i am wondering what are the advantages of IPC compared to WCF services – user1948874 Oct 16 '13 at 13:45
  • 1
    Finally Named Pipes were the easiest way for me, i used WCF to implement it. For those who are interested this Tutorial is really helpful. [Create a Intra-Application Named Pipe using WCF in .Net using C#; IPC Communications](http://omegacoder.com/?p=101) – user1948874 Oct 18 '13 at 09:35