Dreamine.Logging.Wpf 1.0.2
Dreamine.Logging.Wpf 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
WpfLogUiDispatcher.cs
이 파일의 문서화 페이지로 가기
1using System;
2using System.Windows;
3using System.Windows.Threading;
4
6{
16 {
25 private readonly Dispatcher _dispatcher;
26
36
46 : this(Application.Current?.Dispatcher ?? Dispatcher.CurrentDispatcher)
47 {
48 }
49
74 public WpfLogUiDispatcher(Dispatcher dispatcher)
75 {
76 _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
77 }
78
103 public void Invoke(Action action)
104 {
105 ArgumentNullException.ThrowIfNull(action);
106
107 if (_dispatcher.CheckAccess())
108 {
109 action();
110 return;
111 }
112
113 _dispatcher.Invoke(action);
114 }
115
140 public void BeginInvoke(Action action)
141 {
142 ArgumentNullException.ThrowIfNull(action);
143
144 if (_dispatcher.CheckAccess())
145 {
146 action();
147 return;
148 }
149
150 _dispatcher.BeginInvoke(action, DispatcherPriority.Background);
151 }
152 }
153}