|
-
Aug 23rd, 2012, 06:52 PM
#1
Thread Starter
Hyperactive Member
Why won't this PictureBox event fire?
I have an application with a PictureBox... it reads a record from the database to get a file path, then loads that image into the picturebox. When the image load is finished, it then is supposed to fire the LoadCompleted event and kick off further processing. Though the image loads fine and the program continues executing, the LoadCompleted event does not fire, so I run into problems down the road.
Here is where I configured the event:

And here's the code for the event itself:
Code:
private void pictureBox1_LoadCompleted(object sender, AsyncCompletedEventArgs e)
{
wrdReco.InitNewWord();
wrdReco.AddPhrase(Word);
wrdReco.Listen();
lblResults.ForeColor = Color.White;
lblResults.Text = "";
wrdReco.StartListening();
}
I placed a break-point on the first line in the event handler, and it is never reached. Since the speech reco grammar is never created, errors occur a little later when I try to actually use the microphone.
Any ideas why the stupid event handler won't fire? It was working earlier, but the changes I made since shouldn't have affected the PictureBox control or its events.
-
Aug 23rd, 2012, 07:12 PM
#2
Thread Starter
Hyperactive Member
Re: Why won't this PictureBox event fire?
I've got a shoddy workaround... created a timer that fired after 1.5 seconds and performed the same steps as in the event handler. As long as the image is loaded in that time frame, that will work fine. But the event handler SHOULD fire when the image finishes loading, and that's the functionality I want.
-
Aug 23rd, 2012, 08:46 PM
#3
Re: Why won't this PictureBox event fire?
How are you loading the image?
Based on this page the event will only fire when using one of the LoadAsync methods, which it says is the method "LoadAsync".
If you're just using "Load" it won't fire the event.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|