#9
(11 May, 2020 - 04:52 PM)Suspect Wrote: Show More
(10 May, 2020 - 10:24 PM)SioVer Wrote: Show More
(09 May, 2020 - 04:35 PM)Suspect Wrote: Show More
In C# Integers are immutable, therefore simply checking the difference between two values after a minute wouldnt suffice, Although it can be done easily by making an Integer that is Mutable.
 
Code:
 
private void getChecksPerMinute()
{
Thread.CurrentThread.IsBackground = true;

while (globalProperties.IsRunning)
{
if (globalProperties.Attempts > 0) // <-- this should be your int where you add a successful attempts to
{
var MutableInt = new MutableInteger(globalProperties.Attempts);
MutableInt.set(globalProperties.Attempts);
var currentValue = MutableInt.intValue();


Thread.Sleep(TimeSpan.FromMinutes(1));


var CalcDifference = globalProperties.Attempts - currentValue;
HelperMethods.Invoke(function: ReqSec, CalcDifference.ToString(Thread.CurrentThread.CurrentCulture));

}
else
Thread.Sleep(TimeSpan.FromSeconds(2));
}
}


Classes Needed:
 
Code:
 
public static class HelperMethods
{
public static void Invoke(Control function, string text)
=> function.Invoke((MethodInvoker)delegate { function.Text = text; });

}
Code:
 
public class MutableInteger
{
private int value { get; set; }

public MutableInteger(int value)
=> this.value = value;

public void set(int value)
=> this.value = value;

public int intValue()
=> value;
}

using System.Threading.Thread; will also be needed.

You're Welcome.

Oh I forgot to add that I want this in c#

I've never really seen things such as MutableInteger before, is this in c#? if so, could you explain a little better? thanks

This is C#. MutableInteger is the class name basically in C# Integers are Immutable. What does Immutable mean? Well it means that you cannot store the same Value independently from the same changing variable value, Therefore you need to make it Mutable to be able to store a value at one point so we can come back to it later. 

You will have to do more research on Immutable and Mutable Types in C# if you want to have a more broad spectrum I am just posting the solution for your CPM Function.

"=>" are called Lambda Expressions. these are used to make the code more readable I use them wherever I can and I recommend you do the same. Clean precise code > Spaghetti messy code all day long.

(10 May, 2020 - 12:41 AM)igv34673AR Wrote: Show More
To you, but wanted to ask u a question. I can in pm?
<not for cpm>

Yes Please make use of the quote feature of the forum infuture, so people can see who you are talking to Thanks. PM me or Telegram me I am most active on Telegram.

Alright, will do

Thanks <3