Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



 1779

「 How to make CPM Function? 」

by SioVer - 09 May, 2020 - 03:00 AM
This post is by a banned member (SioVer) - Unhide
This post is by a banned member (Pruned110902) - Unhide
8.433
Posts
792
Threads
5 Years of service
#2
(This post was last modified: 09 May, 2020 - 03:01 AM by Pruned110902.)
idkkkk
[Image: image.png]
Quality Handcrafted Accounts Verified For Your Needs
This post is by a banned member (Suspect) - Unhide
Suspect  
Registered
75
Posts
2
Threads
4 Years of service
#3
(This post was last modified: 09 May, 2020 - 04:41 PM by Suspect.)
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.

 
This post is by a banned member (Aqua69tic) - Unhide
This post is by a banned member (Suspect) - Unhide
Suspect  
Registered
75
Posts
2
Threads
4 Years of service
#5
(09 May, 2020 - 04:38 PM)igv34673AR Wrote: Show More
Can u explain a little better?

Who are you talking to?

 
This post is by a banned member (Aqua69tic) - Unhide
This post is by a banned member (SioVer) - Unhide
This post is by a banned member (Suspect) - Unhide
Suspect  
Registered
75
Posts
2
Threads
4 Years of service
#8
(This post was last modified: 11 May, 2020 - 04:55 PM by Suspect.)
(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.

 

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 2 Guest(s)