15
Answers

WndProc(ref Message m) problem

Joel Reid

Joel Reid

12y
14k
1
I have overriden the WndProc method for a burning application I've been working on. I do this to detect DEVICEARRIVAL and DEVICEREMOVECOMPLETE.

I have a Burner class. When this class object is initialized on the burner form, it initializes a backgroundworker. I also have a method inside the Burner class called 'Burn' that will eventually call _backgroundBurnerWorker.RunWorkerAsync()

So if you think about it in a linear fashion it would go like this:

Burn button clicked -> Burner.Burn - > BackgroundBurnerWorker.RunWorkerAsync() - > Back to the form thread here which calls the WndProc method. At this point it goes into a seemingly endless loop and never actually runs the DoWork method.

I've tried moving the base.WndProc to the top of the overriden method and it works when I run it in debug mode but not when I install it.

I would prefer to break out of the WndProc method so that the DoWork can actually burn a disc and report progress but I am unclear of how I should do this. Suggestions would be wonderful!

If there is an easier way to detect when media has been inserted or removed, please do share!

Answers (15)