반응형
UI 스레드의 디스패처를 입수하려면 어떻게 해야 합니까?
UI 스레드를 가져올 방법이 있습니까?DispatcherUI 요소에 대한 참조가 없는 경우
정적 응용 프로그램인스턴스에서 UI 디스패처를 가져올 수 있습니다.Application.Current.Dispatcher
확인하실 수 있습니다.Application.Current셧다운 시퀀스 중에 클리어 할 수 있기 때문에 null의 경우는 우선입니다.
WPF를 사용하고 있는 WinForms 어플리케이션(이 경우는 Esri's Arcmap.exe)에서 사용하는 경우, 이하가 훨씬 효과적입니다.
private System.Windows.Threading.Dispatcher Dispatcher { get; set; }
// I put this in my view model constructor as it MUST be called from UI thread
Dispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;
다른 방법(호출과 관련된 것)new System.Windows.Application()채우다System.Windows.Application.Current)는 새로운 WPF 창을 열고 닫을 때마다 문제를 일으켰습니다.이뿐만 아니라System.Windows.Application.Current그러나 나는 더 이상 그들의 새로운 창문을 열 수 없었다.InitializeComponents()메서드, 모두 실패:
System.InvalidOperation예외: '어플리케이션 개체를 종료하고 있습니다.'
지금까지 새로운 솔루션은 이러한 부작용 없이 작동하고 있습니다.
언급URL : https://stackoverflow.com/questions/2663070/how-do-i-get-the-ui-threads-dispatcher
반응형
'programing' 카테고리의 다른 글
| Visual Studio 코드 터미널, 관리자 권한으로 명령을 실행하는 방법 (0) | 2023.04.20 |
|---|---|
| POI에서 Excel 워크시트 복사 (0) | 2023.04.20 |
| imageEdgeInsets 및 titleEdgeInsets와의 UIButton 텍스트 및 이미지 정렬 (0) | 2023.04.20 |
| KeyVaultErrorException:작업에서 잘못된 상태 코드 '금지됨'을 반환했습니다. (0) | 2023.04.20 |
| 텍스트 길이를 기준으로 UILabel 너비를 계산하는 방법은 무엇입니까? (0) | 2023.04.20 |