コード例 #1
0
        private void SendToChannel(string channelName, string dataType, string message)
        {
            channelName.Requires().IsNotNullOrWhiteSpace();
            message.Requires().IsNotNullOrWhiteSpace();

            using (var dataGram = new WinMsgDataGram(serializer, channelName, dataType, message))
            {
                var dataStruct = dataGram.ToStruct();
                var filter     = new WindowEnumFilter(XDWinMsgListener.GetChannelKey(channelName));
                var winEnum    = new WindowsEnum(filter.WindowFilterHandler);
                foreach (var hWnd in winEnum.Enumerate())
                {
                    IntPtr outPtr;
                    Native.SendMessageTimeout(hWnd, Native.WM_COPYDATA, IntPtr.Zero, ref dataStruct,
                                              Native.SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, 1000, out outPtr);
                }
            }
        }
コード例 #2
0
        private void SendToChannel(string channelName, string dataType, string message)
        {
            channelName.Requires().IsNotNullOrWhiteSpace();
            message.Requires().IsNotNullOrWhiteSpace();

            using (var dataGram = new WinMsgDataGram(serializer, channelName, dataType, message))
            {
                var dataStruct = dataGram.ToStruct();
                var filter = new WindowEnumFilter(XDWinMsgListener.GetChannelKey(channelName));
                var winEnum = new WindowsEnum(filter.WindowFilterHandler);
                foreach (var hWnd in winEnum.Enumerate())
                {
                    IntPtr outPtr;
                    Native.SendMessageTimeout(hWnd, Native.WM_COPYDATA, IntPtr.Zero, ref dataStruct,
                        Native.SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, 1000, out outPtr);
                }
            }
        }
コード例 #3
0
        private void SendToChannel(string channelName, string dataType, string message)
        {
            Validate.That(channelName).IsNotNullOrEmpty();
            Validate.That(message).IsNotNullOrEmpty();

            // create a DataGram instance, and ensure memory is freed
            using (var dataGram = new WinMsgDataGram(serializer, channelName, dataType, message))
            {
                // Allocate the DataGram to a memory address contained in COPYDATASTRUCT
                Native.COPYDATASTRUCT dataStruct = dataGram.ToStruct();
                // Use a filter with the EnumWindows class to get a list of windows containing
                // a property name that matches the destination channel. These are the listening
                // applications.
                var filter  = new WindowEnumFilter(XDWinMsgListener.GetChannelKey(channelName));
                var winEnum = new WindowsEnum(filter.WindowFilterHandler);
                foreach (var hWnd in winEnum.Enumerate())
                {
                    IntPtr outPtr;
                    // For each listening window, send the message data. Return if hang or unresponsive within 1 sec.
                    Native.SendMessageTimeout(hWnd, Native.WM_COPYDATA, IntPtr.Zero, ref dataStruct,
                                              Native.SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, 1000, out outPtr);
                }
            }
        }
コード例 #4
0
        private void SendToChannel(string channelName, string dataType, string message)
        {
            Validate.That(channelName).IsNotNullOrEmpty();
            Validate.That(message).IsNotNullOrEmpty();

            // create a DataGram instance, and ensure memory is freed
            using (var dataGram = new WinMsgDataGram(serializer, channelName, dataType, message))
            {
                // Allocate the DataGram to a memory address contained in COPYDATASTRUCT
                Native.COPYDATASTRUCT dataStruct = dataGram.ToStruct();
                // Use a filter with the EnumWindows class to get a list of windows containing
                // a property name that matches the destination channel. These are the listening
                // applications.
                var filter = new WindowEnumFilter(XDWinMsgListener.GetChannelKey(channelName));
                var winEnum = new WindowsEnum(filter.WindowFilterHandler);
                foreach (var hWnd in winEnum.Enumerate())
                {
                    IntPtr outPtr;
                    // For each listening window, send the message data. Return if hang or unresponsive within 1 sec.
                    Native.SendMessageTimeout(hWnd, Native.WM_COPYDATA, IntPtr.Zero, ref dataStruct,
                                              Native.SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, 1000, out outPtr);
                }
            }
        }