1
응용 프로그램 시작시 스플래시 sceen 레이블을 업데이트하여 사용자에게 무슨 일이 일어나는지 알려주는 가장 좋은 방법은 무엇입니까? 문제는 스플래시 화면이 override 메서드로 만들어지고, 업데이트는 "this.SplashScreen"에 액세스 할 수없는 정적 main 메서드 내에서 수행되어야한다는 것입니다.SingleInstanceApplication에서 스플래시 레이블 업데이트 : WindowsFormsApplicationBase
class SingleInstanceApplication : WindowsFormsApplicationBase
{
[STAThread]
static void Main(string[] args)
{
SetSplashInfo("Data configuration", "Applying DataDirectory");
//Can't be done, this method is static**
//Do some stuff, code removed for reading purposes
}
protected override void OnCreateSplashScreen()
{
this.SplashScreen = new TestSplash();
this.SplashScreen.TopMost = true;
base.OnCreateSplashScreen();
}
private void SetSplashInfo(string txt1, string txt2)
{
if ( this.SplashScreen == null)
return;
TestSplash splashFrm = (TestSplash)this.SplashScreen;
splashFrm.label1.Text = txt1;
splashFrm.label2.Text = txt2;
}
}
고맙지 만 작동하지 않는 것 같습니다. 'instance'가 null 인 경우 (Main에서) 또는 'override void OnCreateMainForm'내에서 인스턴스에 액세스하는 경우 '크로스 스레드 연산이 유효하지 않습니다.'... –
SingleInstanceApplication 객체를 만든 후 * 사용할 수 있습니다. 예, SplashScreen에서 BeginInvoke() 메서드를 사용해야합니다. 다른 스레드에서 실행됩니다. 도움이 필요하면 Control.BeginInvoke() 문서를 확인하십시오. –
미안 .. 꽤 어리 석 었어 ...--). 모든 도움에 감사드립니다! –