console to winform and vice versa sample

Jul 29, 2010 at 3:15 PM
Edited Jul 29, 2010 at 3:19 PM
Hi I am looking for a sample which shows communication between console to winform and vice vers. I have looked at the sample DemoWinformsInteraction but it appears like this is a single process communication. Thanks
Coordinator
Jul 29, 2010 at 3:29 PM
There is no difference between single process communication and multi process communication. just put the client and server code in different processes and it will work. We co-located clients and servers in the same EXE only for simplicity reasons. It´s easier to try out the samples that way.
Jul 30, 2010 at 9:10 AM
Edited Jul 30, 2010 at 9:18 AM
ralfw wrote:
There is no difference between single process communication and multi process communication. just put the client and server code in different processes and it will work. We co-located clients and servers in the same EXE only for simplicity reasons. It´s easier to try out the samples that way.

Hi Ralf
Here is what i have done to try this in DemoWinformsInteraction sample:

1. Add a new console app to the solution DemoWinformsInteraction.
2. Exclude from project DemoWinforms the class Worker.cs
3. Copied Worker.cs to console app
4. Added reference to console in demowinforms
5. Run Demowinforms
6. Run the console app
7. Click on StartNotifications in demo winforms
8. Notice that the console app remains blank

Here we would like the Console.WriteLines to be displayed in the console window.
Please let me know if we missed something.

 

Here is the code in the ConsoleApp:

****************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Ccr.Core;
using XcoAppSpaces.Core;
using System.Threading;

namespace ConsoleApplication1
{
    private static readonly Port<Port<int>> notifier;
        private static readonly Port<int> notificationPort;
        static int i = 0;
        [XcoConcurrent]
        static void Main(string[] args)
        {
            if (i < 10)
            {
                Console.WriteLine("  firing notification {0} on thread {1}", i, Thread.CurrentThread.GetHashCode());
                notificationPort.Post(i);
                Thread.Sleep(200);
                i++;
            }
        }
   
}

****************************************************

Thanks

Coordinator
Jul 30, 2010 at 11:20 AM

Sorry, I don´t understand: The code you included in your comment is the only code in the console app? How can it run? Where´s the app space hosting the worker?

What you can do to find out what´s happening is, you post messages wrapped in a causailty. That way you can check if any exception is thrown during async processing.

Jul 30, 2010 at 12:51 PM

Sorry abuot that.

I have added the above console app to this DemoWinformSample solution and runnin 2 of em.

When the button is clicked in the form i would like to generate the Console.WriteLines in the above Console app.

Please let me know if you need more info.

Thanks

 

Coordinator
Jul 30, 2010 at 3:53 PM

This does not answer my question, though. Please show me the complete (!) code your console app. There needs to be more than the worker you posted above.