기본 창을 렌더링 할 때 gif를로드하는 창을 만들어야합니다. 몇 가지 기사를 읽고이 목적을 위해 새로운 스레드를 만들어야한다는 결정을 내립니다. 내가 ShowLoading()
를 호출하고 내가 원하는처럼 다음 HideLoading()
모든 작품 때WPF 다른 STA 스레드의 레크리에이션 창
LoadingDialog _loadingDlg;
Thread loadingThread;
public void ShowLoading()
{
loadingThread = new Thread(new ThreadStart(loadingThreadWork));
loadingThread.SetApartmentState(ApartmentState.STA);
loadingThread.Start();
}
private void loadingThreadWork()
{
_loadingDlg = new LoadingDialog();
_loadingDlg.Show();
System.Windows.Threading.Dispatcher.Run();
}
public void HideLoading()
{
_loadingDlg.Dispatcher.InvokeShutdown();
}
처음 : 나는 그런 일을 한 결과 this article
에서처럼했다. 내가 두 번째 시간에 ShowLoading()
를 호출 할 때하지만 메시지 The calling thread cannot access this object because a different thread owns it
와
_loadingDlg.Show();
에서 예외가.
어떻게 될 수 있습니까? _loadingDlg
은 이전 행과 동일한 스레드에서 작성됩니다.
왜 새 창을 만드나요? 중앙 집중식 그리드를 만들고 가시성을 전환하는 것이 왜 좋은가요? –