Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Making a button clickable every 10 seconds.

Edit: im stupid and was looking in the wrong section.
On a new thread, also turn illegalcrossthreading off

while (true)
{
Thread.sleep(10000);
button1.enabled = !button1.enabled;
}
Please dont use thread.sleep() if you really need this feature check system time. then have a whille loop that says while currenttime < time + 10
buutton is unclickable
The correct way to do it is:

Code
var timer = new Timer { Interval = 10000 };
t.Tick += delegate { button1.Enabled = !button1.Enabled; };
t.Start();
(Dec 3, 2014 03:48 PM)Agent Raigar Wrote:  Please don't.
Also,

There isn't a correct or wrong way to do this.

Okay, let me paraphrase:

The easiest and cleanest way to do it.
(Dec 3, 2014 04:06 PM)Corios Wrote:  actually yes there is, because this will turn the button on and off every 10 seconds. Not what the OP wants. What if he doesn't click it in the 10 seconds? it'll disable it for the next 10.

Oops, my bad. That's what you get for only reading the title. 🤦‍♂


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by LeonieHackPetaBytes2Jan 23, 2019 05:10 PM 1 227 Jan 23, 2019 05:10 PM
Last Post: 0xDEAD10CC
[Shell] by ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™Nov 26, 2018 05:48 AM 9 409 Nov 26, 2018 05:48 AM
Last Post: pms
[C#] by KaleMar 7, 2016 05:01 PM 4 186 Mar 7, 2016 05:01 PM
Last Post: Kale