Categories > Coding > C# >

Can the while command replace timer in certain situation

Posts: 709

Threads: 55

Joined: Feb, 2021

Reputation: 32

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#

  • 0

Added

@ImmuneLion318 yeah yeah thats good and all but will u answer the question the thread is about

  • 0

Why are you here

MINISHXP

[REDACTED]

Posts: 976

Threads: 3

Joined: Jan, 2021

Reputation: 9

Replied

thats gonna freeze the ui

  • 0

Posts: 709

Threads: 55

Joined: Feb, 2021

Reputation: 32

Replied

  • 0

Why are you here

Posts: 1477

Threads: 95

Joined: Oct, 2019

Reputation: 103

Replied

@Haxim

I Guess You Could Do Something Like This

new Thread(() => 
{
     while (ValidateAttachment())
     {
           /* Change Stuff */
     }
}).Start();
  • 0

Posts: 0

Threads: 0

Joined: ?

Reputation:

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.

  • 0

Posts: 709

Threads: 55

Joined: Feb, 2021

Reputation: 32

Replied

Thanks for the input everyone

  • 0

Why are you here

TERIHAX

i say im gay as a joke 🙀

Posts: 2243

Threads: 102

Joined: Jul, 2020

Reputation: 32

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

  • 0

Posts: 31

Threads: 7

Joined: Sep, 2020

Reputation: 8

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

 

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )