Categories > Coding > C# >
Can the while command replace timer in certain situation
Posted
Ok maybe im dumb or something but yk how there is a dumb timer that idiots use to make something green when attached and red when other wise. Cant u just go
while (isAPIAttached)
{
//do the thing
}
am I dumb or does this seem more efficient than a timer, I guess people just never learned while aka they don't really know any c#
Added
@ImmuneLion318 yeah yeah thats good and all but will u answer the question the thread is about
Cancel
Post
Why are you here
Replied
thats gonna freeze the ui
Cancel
Post
Why are you here
Replied
I Guess You Could Do Something Like This
new Thread(() =>
{
while (ValidateAttachment())
{
/* Change Stuff */
}
}).Start();
Cancel
Post
Replied
Just execute it in a seperate thread or Task so you don't stop your main UI thread.
while (isAPIAttached) {
// code here
Thread.Sleep(1);
}
Why timers tend to be used are beyond me, but it could be a performance thing? Not sure.
Cancel
Post
Replied
Thanks for the input everyone
Cancel
Post
Why are you here
Replied
@MINISHXP if you do an await Task.Delay then it wont freeze the UI, u could make another thread which might be a bit better idrk
Cancel
Post
Replied
That would pause the current Thread meaning your Interface would be frozen, You need to create a new thread and run that code as Immune said.
Personally I have written a class for my projects that has an event for when my exploit attaches for example I can do:
api.OnAttached += ..
I recommend making something like that since its easy to use between different projects and It can be used for multiple stuff as well.
If you do not know how to use events check out: docs
Cancel
Post
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post