Splash Screen waiting until thread finishes

前端 未结 5 794
醉梦人生
醉梦人生 2020-11-22 07:46

I still have a problem with the splash screen. I don\'t want to use the property SC.TopMost=true.

Now my application scenario is as follows:

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 08:15

    You really should give more details about your problem. I could be completely wrong, but I'm going to take a shot in the dark. From what I'm imagining is going on and you want, you want the splash screen to show, do some processing in another thread, then the splash screen to go away when finished.

    To do this, you're going to want to move the GetFromServer() call to a BackgroundWorker. Then move the

        this.Hide();
        _serverData = new ArrayList();
        _thisData.Add(_allServerNarrators);
        _thisData.Add(_serverNarrators);
    

    code to the BackgroundWorker_RunWorkerCompleted event handler.

    To use the BackgroundWorker:

    1) Initialize the BackGroundWorker

      BackgroundWorker myWorker = new BackgroundWorker();
    

    2) Add event handlers

      myWorker.DoWork += new DoWorkEventHandler(myWorker_DoWork);
      //put the work you want done in this one
    
      myWorker.RunWorkerCompleted += 
          new RunWorkerCompletedEventHandler(myWorker_RunWorkerCompleted);
      //this gets fired when the work is finished
    

    3) Add code to the event handlers.

    4) Call myWorker.RunWorkerAsync() to start working.

    As a separate note, you don't seem to be doing anything with the ArrayList that you're passing to the splash screen's constructor. Is this intended?

提交回复
热议问题