Mouse Down Event Triggers While Looping

kentheprogger

Newcomer
Joined
Apr 2, 2006
Messages
24
I have an application that searches a CSV document. The document has over 8,700 lines so it takes a few seconds for it to get through it, which is represented by a progress bar. I have a picturebox that acts as a button that triggers this sub routine. I have a stop button which I want to trigger while the search is running. The problem is, once I am searching, no matter where I click, it triggers the button that searches the CSV.

I have tried Application.DoEvents() in a few different places and this hasn't fixed the problem.

Any help would be greatly appreciated!!

Thanks!
 
So if the search is already running and you click btnStop, it restarts the search or just has no noticable effect? What code do you have for btnStop_Click?
 
I have no idea how this can be triggering the same event regardless of where you click. But if you wish to use the interface properly whilst the search is going on, your best option would be to run the search on a seperate thread.
 
Cags said:
I have no idea how this can be triggering the same event regardless of where you click. But if you wish to use the interface properly whilst the search is going on, your best option would be to run the search on a seperate thread.

Okay, sorry I probabally could have made it a bit more in depth:

There are two buttons that involve this problem:

(These buttons are actually PictureBoxes because the GUI uses buttons that have an up and down image)

btnExpandSearch
btnStopSearch

When I click btnExpandSearch, I have a loop that searches through over 8,700 lines of text. Whenever the search is in progress, clicking anywhere on the form will trigger the mouseDown event for btnExpandSearch and it will start the search over again.

I would like to use a seperate thread, however I havn't much experience in that area. If you could point me to a good tutorial or book I can study this in I would greatly appreciate it.

Thanks again!
 
I studied into Threading and I have done pretty well with it.

It fixed the problem I was having with the buttons.

I decided to use threading to load six movies onto a form and pause them at the first frame. The problem with this is that I need to know what thread is last to finish so I can set the movies to visible to avoid seeing the nasty play till first frame pause sequence.

Any ideas?

I'm using STA due to the Windows Media Controls not being able to work with MTA so I cannot use the WaitHandle.WaitAll(WaitAllEvents), which would be ideal!

So any STA equivalent to that would be excellent! Thanks!
 
kentheprogger said:
I studied into Threading and I have done pretty well with it.

It fixed the problem I was having with the buttons.

I decided to use threading to load six movies onto a form and pause them at the first frame. The problem with this is that I need to know what thread is last to finish so I can set the movies to visible to avoid seeing the nasty play till first frame pause sequence.

Any ideas?

I'm using STA due to the Windows Media Controls not being able to work with MTA so I cannot use the WaitHandle.WaitAll(WaitAllEvents), which would be ideal!

So any STA equivalent to that would be excellent! Thanks!

Solved! Added a Do Loop that would loop nothing until all six movies were loaded. It looks great! Thanks for the help, I can see threading will be extremely useful in the future.
 
Back
Top