Autor Beitrag
Macoy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 31



BeitragVerfasst: Do 06.04.06 16:31 
Hallo,

Mein Programm muss eine wav datei öffnen und die Samples komplett einlesen. Nun dauert das ein bisschen und ich möchte den user ja nicht im dunkeln stehen lassen, also musste ein Dialog her, der sagt, was grad so abläuft.

Nun habe ich einen selsamen Effekt:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
    public void TryReadData(uint channel)
    {
      lbInfo.Text = "Reading data into memory. Please wait.";
      
      try{
        fileToOpen.ReadData(channel); // scheinbar ruft er das zuerst auf
      }catch(Exception ex)
      {
        lbInfo.Text = "Failed to read data: " + ex.Message;
        return;
      }
      
      //lbInfo.Text = "Operation completed sucessful.";
      
    }


Nämlich beim Aufruf wird ZUERST ReadData() aufgerufen, und dann erst der Text in den Label geschrieben (was dann allerdings schon zu spät ist) . Eigentlich soll ja erst dastehen "Reading ... " und dann das laden losgehen, aber es ist genau andersrum. Ich kann mir dieses Verhalten einfach nicht erklären. Mit Invalidate() oder ähnlichem habe ich schon versucht, ein Repaint the labels zu erzwingen, ohne Wirkung.

Das gleiche Problem hier: Zurerst wird TryToRead() aufgerufen, erst danach wird die Checkbox Disabled

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
    void CbChannelSelectedIndexChanged(object sender, System.EventArgs e)
    {
      cbChannel.Enabled = false// dies passiert erstnach nach aufruf von TryReadData(...)
      if(cbChannel.SelectedIndex == 0)
      {
        TryReadData(1);
      }
      else
      {
        TryReadData(2);
      }
    }
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6386
Erhaltene Danke: 146

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 06.04.06 16:41 
Schonmal ein Refresh für dein Label versucht?
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
    public void TryReadData(uint channel)
    {
      lbInfo.Text = "Reading data into memory. Please wait.";
      lbInfo.Refresh(); // So etwa
      
      try{
        fileToOpen.ReadData(channel); // scheinbar ruft er das zuerst auf
      }catch(Exception ex)
      {
        lbInfo.Text = "Failed to read data: " + ex.Message;
        return;
      }
      
      //lbInfo.Text = "Operation completed sucessful.";
      
    }