last day (14 days later) » 

12:01 PM
3
A: Check if event (doubleClick) is running

SteveJust disable the event handler public void listView_DoubleClick(object sender, EventArgs e) { try { listView.DoubleClick -= listView_DoubleClick; // Now, even if func1 causes a DoubleClick event, // or user manages to trigger a DobuleClick // there i...

 
This really looks nice. But I cant disable the handler. It gets fired up anyway. I just changed the listView-name in your code and inserted it into mine. No error raised. It just runs through it again.
 
@C4ud3x look at the code in the form.designer.cs InitializeComponent method. You will find how the Visual Studio IDE links your event handler code to the event DoubleClick of the ListView in question. The process is the same.
Do you have the same event handler assigned to more than one listview?. The disabling -= affects only the listview on the left of the -=, not all the listview that are linked to the same event handler
 
Nope. It is only this one listView and also only this one handler.
 
Try to use the updated code with the generic Control.
 
Hah. I really thought "this is it!". But sorry, it is still fired up.
 
12:01 PM
Please do a full search of your code (CTRL+SHIFT+F) for listView_DoubleClick and verify if there are some duplicates somewhere.
 
I searched through the hole project. There are only this 4 places: designer.cs, the event and our try-finally inside the event. Nothing more.
Hi.
Please give me 5 mins for a break.
 
I am thinking to something to replace momentarily the func1 and see if the call is still executed
for example
for(i = 0; i < 1000000; i++) Application.DoEvents();
 
Im back. Sorry, really had to take a break.
Alright. Ill try that out.
Strange thing. This one is working.
What I did now: msgbox.show("fired") -> lable.text = "started" -> for(..) -> lable.text = "ended".
As long as the label shows "started" (the for-loop is running) i cant raise a new msgbox with double clicking the listview. So this one is working correctly.
What my func1 is doing: Adding some textboxes to the control and changing the focus to the textboxes. Nothing more.
 
12:29 PM
MessageBox is modal. It blocks everything and so there is no way that the event is reentered until the messagebox is closed. This is the reasong I suggested to use Application.DoEvents. It allows other events to be processed and so you should be able to doubleclick again the listview.
 
But hey, when using Application.DoEvents only, I havnt got any vusial proof if my double-click is fired.
To your argument about the msgbox: I raised the for loop up to 10 million. Therefore I got enough time to close the messagebox and doubleclick again.
And this is what i did. Doubleclick -> label changed -> msgbox showed up -> msgbox closed -> label is still on "started" -> double clicked again -> nothing happens -> label switches to "ended" some seconds later.
THEN the double click is working again.
 
We can only suppose that something in func1 reenables this event handler.
However I would try with a Console.WriteLine("Event entered") as the first line of the event handler. You could check the output window for the message.
 
I guess I found the mistake.
Really stupid one. Ill proof it first, give me a minute.
Yeah shit. First of all: Im really sorry for taking so much time from you. The mistake wasnt made by you.
func1 isnt waiting for user input. It just enables an textbox and an event for this textbox (enter-pressed).
So func1 is running through the hole code-part and enabling the handler for the listview again.
I made the big mistake. The "disabled double click" inside the func1 is in the wrong plae.
 
12:47 PM
Well that's explain everything. Good work and don't worry. I am stuck at the PC for today afternoon babysitting so it is not a great deal.
 
place*. It should not fire up as long as the enter-pressed-event exists.
Haha. Alright. Thank you very much for helping me out. Your first code should work as expected.
Im babysitting too.
My babies rather are employees haha.
 

last day (14 days later) »