When I develop an application with VS.NET C#, when I click more than
one time on a button, it seems to execute many threads of the same
function.
How to disable it?
thanks 6 3689
when you click the button, the first line of code should disable the button.
MyButton.Enabled = false;
Then call your code. When you are done with your operation, make sure to
re-enable the button.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"?code" <mi***********@hotmail.com> wrote in message
news:48**************************@posting.google.c om... When I develop an application with VS.NET C#, when I click more than one time on a button, it seems to execute many threads of the same function. How to disable it? thanks
Why on earth is C# doing this and who decided on something like that!!??
Just kidding, back from reading your blog... ;o)
"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.com> wrote in message
news:jgXxd.267204$HA.75771@attbi_s01... when you click the button, the first line of code should disable the button.
MyButton.Enabled = false;
Then call your code. When you are done with your operation, make sure to re-enable the button.
-- --- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- "?code" <mi***********@hotmail.com> wrote in message news:48**************************@posting.google.c om... When I develop an application with VS.NET C#, when I click more than one time on a button, it seems to execute many threads of the same function. How to disable it? thanks
?code,
It doesn't execute more than one thread unless you explicitly tell it
to. If you have code that creates a new thread, then that code is going to
run very fast, because it will spawn the new thread, and then that new
thread will execute new code parallel to the code running in the UI thread
(well, maybe not exactly, depending on number of processors, etc, etc).
What you need to do is set a flag indicating that you already spawned a
thread, and if that flag is set, do not spawn another thread when the button
is pressed.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"?code" <mi***********@hotmail.com> wrote in message
news:48**************************@posting.google.c om... When I develop an application with VS.NET C#, when I click more than one time on a button, it seems to execute many threads of the same function. How to disable it? thanks
I think threads should be subbed for buffered clicks?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl... ?code,
It doesn't execute more than one thread unless you explicitly tell it to. If you have code that creates a new thread, then that code is going to run very fast, because it will spawn the new thread, and then that new thread will execute new code parallel to the code running in the UI thread (well, maybe not exactly, depending on number of processors, etc, etc).
What you need to do is set a flag indicating that you already spawned a thread, and if that flag is set, do not spawn another thread when the button is pressed.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"?code" <mi***********@hotmail.com> wrote in message news:48**************************@posting.google.c om... When I develop an application with VS.NET C#, when I click more than one time on a button, it seems to execute many threads of the same function. How to disable it? thanks
Huh?
"Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk> wrote in message
news:e0****************@tk2msftngp13.phx.gbl... I think threads should be subbed for buffered clicks?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... ?code,
It doesn't execute more than one thread unless you explicitly tell it to. If you have code that creates a new thread, then that code is going to run very fast, because it will spawn the new thread, and then that new thread will execute new code parallel to the code running in the UI thread (well, maybe not exactly, depending on number of processors, etc, etc).
What you need to do is set a flag indicating that you already spawned a thread, and if that flag is set, do not spawn another thread when the button is pressed.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"?code" <mi***********@hotmail.com> wrote in message news:48**************************@posting.google.c om... When I develop an application with VS.NET C#, when I click more than one time on a button, it seems to execute many threads of the same function. How to disable it? thanks
I'm guessing that what's happening is a button is being clicked multiple
times, and am assuming there's some buffering mechanism in the windows
message handling. Would this not give the appearance of "multiple threads"?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2***************@TK2MSFTNGP10.phx.gbl... Huh?
"Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk> wrote in message news:e0****************@tk2msftngp13.phx.gbl... I think threads should be subbed for buffered clicks?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl... ?code,
It doesn't execute more than one thread unless you explicitly tell it to. If you have code that creates a new thread, then that code is going to run very fast, because it will spawn the new thread, and then that new thread will execute new code parallel to the code running in the UI thread (well, maybe not exactly, depending on number of processors, etc, etc).
What you need to do is set a flag indicating that you already spawned a thread, and if that flag is set, do not spawn another thread when the button is pressed.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"?code" <mi***********@hotmail.com> wrote in message news:48**************************@posting.google.c om... When I develop an application with VS.NET C#, when I click more than one time on a button, it seems to execute many threads of the same function. How to disable it? thanks
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bob Bedford |
last post by:
I create checkboxes using datas from a database (with PHP).
I store all values in an array, as I must pass this value like a Form value.
Now, in some cases, when a checkbox is selected, I must...
|
by: nntp |
last post by:
I have a set of links which I want search engines to crawl them, but I want
to disable them from my visitors, so I will ask the link owners to pay me to
let me enable them.
<a disabled...
|
by: Alpha |
last post by:
How I can disable multi-selection on a datagrid? User now can select
multi-rows on the grid by holding down control key. I don't see such
property for the grid as for the list control. Is there...
|
by: John Grandy |
last post by:
On a .aspx page I have seen commercial controls that serve as replacements
for the <asp:Button> control that immediately disable the button on form
submission so that accidental double-clicks (or...
|
by: Chris |
last post by:
I have an asp.net page say page1.aspx. The form in html code is <form
id = "Form1">
And i want to disable all the fields of the form after some code steps.
I had created a javascript funct:
...
| |
by: Ahmad Jalil Qarshi |
last post by:
Hi!
I have a problem while developing some webpages.The Problem is that:-
How We Can Disable The Controls Of One Web Form From Other Web Form In
Asp.net?
Explanation:-
There Should Be Two...
|
by: Phoe6 |
last post by:
Hi all,
I am trying to disable the NIC card (and other cards) enabled in my
machine to test diagnostics on that card.
I am trying to disable it programmatic using python. I checked python
wmi and...
|
by: Bob Alston |
last post by:
Anyone know how to disable or redefine the Ctrl - hotkey which deletes a
record? I have a multi page form that uses 14 records, each record
handles 1-2 pages of the 18 page form. Occasionally ,...
|
by: Hiren Joshi |
last post by:
Hello All Experts,
I am a Moderate VB Programmer. I am developing one Application at the moment with VB 6.0 and MS Access. Operating System is Win XP. Its a Multi User application.
What I want...
|
by: kfank |
last post by:
I have a multi-line TextBox with a vertical scrollbar that logs data from a realtime process. Currently, whenever a new line is added the textbox scrolls to the bottom so you can see the last...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |