Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Label does not Get Updated

Label does not Get Updated

Scheduled Pinned Locked Moved WPF
csharpasp-netcomquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vimalsoft Pty Ltd
    wrote on last edited by
    #1

    Good Day i have a code which is fired on the Button click even

    //Part 1 -- its not Getting updated
    Status.Background = new SolidColorBrush(Colors.Orange);
    Status.Content = "Exporting, please wait...";

       //Part 2 is working
           Logger.ExportLogToExcel(); 
    
      //Part 3 is Working 
    
            Status.Background = new SolidColorBrush(Colors.Yellow);
            Status.Content = "Exported to Excel Successfully";
    

    What is Part 1 not working. Basically , i am Exporting to Excel , and i am changing the Label that shows the status, i am changing the color and also the contents. but the Dont change i only see "Exported to Excel Successfully" I thought might be that the Export is quick to a point that it immediately jump to Success message. i added a thread to make to sleep for a few seconds before it can export so i see a different background. Thanks

    Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vimalsoft.com vuyiswa[at]vimalsoft.com

    M 1 Reply Last reply
    0
    • V Vimalsoft Pty Ltd

      Good Day i have a code which is fired on the Button click even

      //Part 1 -- its not Getting updated
      Status.Background = new SolidColorBrush(Colors.Orange);
      Status.Content = "Exporting, please wait...";

         //Part 2 is working
             Logger.ExportLogToExcel(); 
      
        //Part 3 is Working 
      
              Status.Background = new SolidColorBrush(Colors.Yellow);
              Status.Content = "Exported to Excel Successfully";
      

      What is Part 1 not working. Basically , i am Exporting to Excel , and i am changing the Label that shows the status, i am changing the color and also the contents. but the Dont change i only see "Exported to Excel Successfully" I thought might be that the Export is quick to a point that it immediately jump to Success message. i added a thread to make to sleep for a few seconds before it can export so i see a different background. Thanks

      Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vimalsoft.com vuyiswa[at]vimalsoft.com

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      I am guessing that everything is done on the main thread so the UI thread locks until the method is completed and the last colour change is effected. Unless you do the export on a separate thread you are not going to see the initial colour change. putting in a delay does not help, move the export to a BGW thread.

      Never underestimate the power of human stupidity RAH

      V 1 Reply Last reply
      0
      • M Mycroft Holmes

        I am guessing that everything is done on the main thread so the UI thread locks until the method is completed and the last colour change is effected. Unless you do the export on a separate thread you are not going to see the initial colour change. putting in a delay does not help, move the export to a BGW thread.

        Never underestimate the power of human stupidity RAH

        V Offline
        V Offline
        Vimalsoft Pty Ltd
        wrote on last edited by
        #3

        i actually tried that initially. by setting the color from another Thread and the Export is obviously in another thread. but still the issue remains , let me keep trying something will post the feedback if i get to the solution.

        Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vimalsoft.com vuyiswa[at]vimalsoft.com

        M 1 Reply Last reply
        0
        • V Vimalsoft Pty Ltd

          i actually tried that initially. by setting the color from another Thread and the Export is obviously in another thread. but still the issue remains , let me keep trying something will post the feedback if i get to the solution.

          Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vimalsoft.com vuyiswa[at]vimalsoft.com

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          No no no, you set the colour BEFORE you launch the BGW that exports the excel, in the BGW compleate method you set the colour the second time. This allows the UI to refresh while the BGW is working.

          Never underestimate the power of human stupidity RAH

          V 1 Reply Last reply
          0
          • M Mycroft Holmes

            No no no, you set the colour BEFORE you launch the BGW that exports the excel, in the BGW compleate method you set the colour the second time. This allows the UI to refresh while the BGW is working.

            Never underestimate the power of human stupidity RAH

            V Offline
            V Offline
            Vimalsoft Pty Ltd
            wrote on last edited by
            #5

            You are 100% Right, i was missing Something. its now working like charm.

            Vuyiswa Maseko, Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code. C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vimalsoft.com vuyiswa[at]vimalsoft.com

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups