Label Visibility under ButtonClick EventHandler
-
Hi Friends, At the click of button i am fetching data from back end which takes a time..so before fetching i am making a label visible with a message saying "Please Wait"..as it can be clear from code below.. private void btnShowDetails_Click(object sender, EventArgs e) { lblShowMessage.visible=true; FetchRecords(); lblShowMessage.visible=false; } but that label is not getting visible at all..what could be the problem..plz assist me in this regard. Thanks, Rahul Agarwal
-
Hi Friends, At the click of button i am fetching data from back end which takes a time..so before fetching i am making a label visible with a message saying "Please Wait"..as it can be clear from code below.. private void btnShowDetails_Click(object sender, EventArgs e) { lblShowMessage.visible=true; FetchRecords(); lblShowMessage.visible=false; } but that label is not getting visible at all..what could be the problem..plz assist me in this regard. Thanks, Rahul Agarwal
Hi! That's simple: Your btnShowDetails_Click method is running on the main UI thread that's responsible for repainting the form. Between making lblShowMessage visible and hiding it again, it's busy fetching some records, so it doesn't have time to repaint the form. Once the button click handler is through, the form can get repainted, but then the label is invisible again. The better solution would be to put FetchRecords in a separate thread and let the UI thread handle just the UI.
Regards, mav -- Black holes are the places where God divided by 0...