110,534
社区成员
发帖
与我相关
我的任务
分享
private void MainWindowLoaded(object sender, RoutedEventArgs e)
{
System.Threading.Thread t1 = new System.Threading.Thread(new System.Threading.ThreadStart(delegate() { changecolor(); }));
t1.IsBackground = true;
t1.Start();
}
private void delay_zusai(object sender,RoutedEventArgs args)
{
System.Windows.MessageBox.Show("123", "abc");
this.Title = "haha";
}
private void changecolor()
{
int i = 0;
while (true)
{
System.Threading.Thread.Sleep(1000);
this.Change_Background(((i++ % 2 == 0) ? "Green" : "Red"));
}
}
delegate void Change_Background_Handle(string String_Color);
void Change_Background(string String_Color)
{
if (this.Dispatcher.Thread != System.Threading.Thread.CurrentThread)
{
this.Dispatcher.Invoke(new Change_Background_Handle(this.Change_Background), String_Color);
}
else
{
this.Background = new System.Windows.Media.SolidColorBrush((System.Windows.Media.Color)(System.Windows.Media.ColorConverter.ConvertFromString(String_Color)));
}
}
EnableWindow(hParent, FALSE); //1
while( GetMessage(&msg, NULL, 0, 0) ) //2
{
if( !quitDialg && !IsDialogMessage(hCurrentDlg, &msg) ) //3
{
TranslateMessage(&msg);
DispatchMessage(&msg); //4
}
}
EnableWindow(hParent, TRUE);
//C#
this.Title = "haha";