Exemple #1
0
        //此方法支持在自动判断是否在非创建线程中被调用
        private void UpdateUi(AsyncFormMessageEvent messageEvent)
        {
            if (!AsyncFormEventBus.ShouldRaise())
            {
                return;
            }

            string value = string.Format("{0}{1}", messageEvent.Message, AutoAppendLine ? Environment.NewLine : string.Empty);

            if (WithPrefix)
            {
                value = messageEvent.DateTimeEventOccurred.ToString("yyyy-MM-dd HH:mm:ss:fff") + " => " + value;
            }
            if (InvokeControl.InvokeRequired)
            {
                InvokeControl.Invoke(UpdateMessage, value);
            }
            else
            {
                UpdateMessage(value);
            }
        }
        //此方法会在非UI线程中被调用
        private void UpdateUi(AsyncFormMessageEvent obj)
        {
            if (!AsyncFormEventBus.ShouldRaise())
            {
                return;
            }

            string value = string.Format("{0}{1}", obj.Message, Environment.NewLine);

            if (WithPrefix)
            {
                value = obj.DateTimeEventOccurred.ToString("yyyy-MM-dd HH:mm:ss:fff") + " => " + value;
            }
            var invoker = GetInvoker();

            if (invoker.InvokeRequired)
            {
                invoker.Invoke(_showStateCallback, value);
            }
            else
            {
                _showStateCallback.Invoke(value);
            }
        }