ipc using Shared and as global MMF

…衆ロ難τιáo~ 提交于 2019-12-08 04:47:29
    static void Main(string[] args)
    {
        FsMomitorIPCCarier data = new FsMomitorIPCCarier("someData");
        IpcAccessorSetting curSrv = new IpcAccessorSetting(IPChannelS.FsMonitor, IpcAccessorThreadNameS.FsmonitorThrd, 0, 2000);
        MMFDepositT FsMonitorSetterDepo = null;
        try
        {
            FsMonitorSetterDepo = new MMFDepositT(curSrv.Channel.ToString(),curSrv.AccThreadName.ToString(), 4096);

            FsMonitorSetterDepo.ReadPosition = curSrv.AccessorSectorsSets.DepoSects.Setter.Read;
            FsMonitorSetterDepo.WritePosition =curSrv.AccessorSectorsSets.DepoSects.Setter.Write;
            Console.WriteLine("MonitorSetterDepo.ReadPosition " + FsMonitorSetterDepo.ReadPosition);
            Console.WriteLine("MonitorSetterDepo.WritePosition " + FsMonitorSetterDepo.WritePosition);

            FsMonitorSetterDepo.DataReceived += new EventHandler<MemoryMappedDataReceivedEventArgs>(FsMonitorSetter_DataReceived);
            FsMonitorSetterDepo.StartReader();
        }
        catch (Exception e)
        {
           Console.ForegroundColor = ConsoleColor.Red;
           Console.WriteLine("MonitorSetterDepo ctor: " + e.Message);
        }

        Console.ForegroundColor = ConsoleColor.Magenta;
        Console.WriteLine("MonitorSetterDepo is now online");

        var msg = data.DipositStrVal.StrValue.Val;
        Console.WriteLine("Data = " + msg);
        bool quit = false;


        while (!quit)
        {
            Console.ReadLine();
            if (!string.IsNullOrEmpty(msg))
            {
                var dataDelvr = data.IpcCarierToByteArray();
                FsMonitorSetterDepo.Write(dataDelvr);
            }
            else
            {
                quit = true;
            }
            //msg = "";
        }

        //DepoTest.statusSet.ForEach(SttM => Console.WriteLine(SttM));

        FsMonitorSetterDepo.Close();
        FsMonitorSetterDepo = null;

    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!