I also tried BackgroundWorker concept Loading animation is working here, but it is not allowing to load the usercontrols and giving an error.
는, 당신은 STA되지 않습니다으로, 귀하의 백그라운드 스레드에서 UI 측에서 아무것도 만지지 수 없습니다 있습니다. 대신 진행률 표시기를 스레드가 수정할 수있는 속성에 바인딩 한 다음 진행률 표시기가 INotifyPropertyChanged 이벤트를 통해 업데이트를 가져옵니다. 예를 들어
, 당신은 ProgressBar
바인딩에 ProgressPercentage
, 또는 IsBusy
결합 불확정 바쁜 표시가 있다면 :
XAML
에서 :
<ProgressBar x:Name="StatusBar"
Maximum="1" Value="{Binding ProgressPercentage}" />
Code
에서 :
using (var backgroundWorker = new BackgroundWorker())
{
backgroundWorker.DoWork += (s, ex) =>
{
IsBusy = true;
StatusText = "Pretending to do something...";
for (int i = 0; i < 100; i++)
{
ProgressPercentage = (i + 1)/100.0D;
Thread.Sleep(100);
}
};
backgroundWorker.RunWorkerCompleted += (s, ex) =>
{
IsBusy = false;
StatusText = "Export Complete.";
};
backgroundWorker.RunWorkerAsync();
}
을 백그라운드 스레드가 작업을 수행하고 대기하는 동안 UI 스레드가 차단되지 않으며 진행률 표시 icator가 진행됨에 따라 업데이트됩니다.
의존성 주입을 사용하고 있습니까? 시작시 또는 어셈블리 자체에서 비즈니스 데이터를로드하는 데 사용합니까? –
예 시작시 데이터를로드하지만 종속성 삽입을 사용하지 않습니다. 외부 파일에서 데이터를 검색하고 페이지로드시 해당 데이터를 기반으로 사용자 컨트롤을 만듭니다. – nandu
LoadSecondPageData의 내용은 무엇입니까? 코드를 게시 할 수 있습니까? – Dilshod