void Start()
        {
            string contextName = "Context" + (IsHost ? ".Host" : ".Client");

            context = CreateContext(contextName);


            DotNetThreadStarter      threadStarter = new DotNetThreadStarter();
            MemoryMappedCommunicator communicator  = new MemoryMappedCommunicator(threadStarter, "Tgrc.Messages.MemoryMap", IsHost);

            proxy = CreateRemoteDispatcher(context, communicator);

            lastSend = DateTime.UtcNow;

            communicator.StartThreads();
        }
示例#2
0
        private static void MemoryMappedTest(string[] args)
        {
            bool isClient = args.Length > 0 && args[0] == "client";
            bool isHost   = !isClient;

            string   contextName = "Context" + (isClient ? ".Client" : ".Host");
            IContext context     = CreateContext(contextName);


            DotNetThreadStarter      threadStarter = new DotNetThreadStarter();
            MemoryMappedCommunicator communicator  = new MemoryMappedCommunicator(threadStarter, "Tgrc.Messages.MemoryMap", isHost);

            RemoteDispatcherProxy proxy = CreateRemoteDispatcher(context, communicator);

            communicator.StartThreads();

            DateTime lastSend = DateTime.UtcNow;

            while (true)
            {
                if ((DateTime.UtcNow - lastSend) > TimeSpan.FromSeconds(1.5))
                {
                    for (int i = 0; i < 500; i++)
                    {
                        IMessage message = CreateBasicMessage(context);
                        context.Dispatcher.Send(message);
                    }

                    lastSend = DateTime.UtcNow;
                }


                context.Dispatcher.DispatchMessages();
                proxy.SendToRemote();
                proxy.ForwardRemoteMessages();
            }
        }