In a ButtonClickEvent you can change the state of a button for instance
Like using Button.IsEnabled = true; (Or false)
In my Button click event code I put an find file routine this routine calls an CRC32 routine
with me so far..
Oke when the CRC32 routine starts I want to display the busyindicator control.
(got it from the extended wpf toolkit).
But this Item is not accessible in the CRC32 routine (also not accessible in find file) only in
the button click routine.
how do I make this control accessible in the CRC32 routine?
Re: Button/busyindicator in other than Click Event
If BusyIndicator is an instance variable or a property, then it's because those two methods, GetDriveAndFile() and CRCChecker(), are static.
If you can change the code of those methods, then either make them non-static, or add to each an additional parameter, e.g. GetDriveAndFile(InstallerMode Mode, BusyIndicator Busy), and then pass along the BusyIndicator available from within InstallClick().
Re: Button/busyindicator in other than Click Event
The CRC routine only returns a false or true value, no updates/events just a math routine
I want to switch on the busyindicator when enetering the CRC routine and turn it off when leaving the CRC.
VS does not let me create GetDriveAndFile(InstallerMode Mode, BusyIndicator Busy)
Re: Button/busyindicator in other than Click Event
Wrap the CRC routine in a BackgroundWorker class and handle the RunWorkerCompleted event. Set the BusyIndicator state before starting the thread and reset it in the RunWorkerCompleted event handler.
Re: Button/busyindicator in other than Click Event
Hi all,
Working on the background thread option from Arjay, does not give me the wanted result, yet.
Apart from that; I came to the conclusion that a VISUAL state change is done after the last bracket.
see code;
Code:
private void InstallClick(object sender, RoutedEventArgs e) //Install Button click
{
BusyIndicator.IsBusy = true;
do some time consuming work, last for about 5 sec.
}
in the first line the busyindicator is set to true, but the change is not visible!
the change is visible after the "do some time etc...." so when the "program pointer" passes the closing bracket.
Is there a way to make the change visible right away? (using something like update/redraw or stuff like that).
Re: Button/busyindicator in other than Click Event
Hi,
I do understand the blocking of the UI thread.
using the background gives me an unstable program.
If I runs it 10 times it crashes 2 times randomly.
This is my "problem";
Pushing/clicking the install button results in the following
- Find File.
- Do a CRC check
- Run it
during the find file portion the window state is normal (with a OpenFileDialog on top of it, when the File is not at the expected place)
during the CRC check the window shows an isbusy indications
during the execution of the file the window state is minimized.
I also had a look at async/await method so far no luck.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.