Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 09:18

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[C#]Parallel Looping

Discussion on [C#]Parallel Looping within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
Naworia's Avatar
 
elite*gold: 12
Join Date: Aug 2011
Posts: 455
Received Thanks: 418
[C#]Parallel Looping

I want a function that gives me looping parallelize.

Example :

Code:
While(a == 1)
{
  Send("{ENTER}");
}

While(b == 3)
{
  Send("{TAB}");
}
I want these 2 loops working for parallel. How can i do? If you know other solve, please say.
Naworia is offline  
Old 07/01/2012, 23:02   #2
 
xNopex's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 827
Received Thanks: 471
Code:
Loop 1
  Send("{ENTER}");
  Send("{TAB}");
EndLoop
???
xNopex is offline  
Old 07/01/2012, 23:07   #3
 
Naworia's Avatar
 
elite*gold: 12
Join Date: Aug 2011
Posts: 455
Received Thanks: 418
I edited for you get understand more ...
Naworia is offline  
Old 07/01/2012, 23:13   #4
 
elite*gold: 1000
Join Date: Apr 2012
Posts: 1,003
Received Thanks: 208
Quote:
while(a == 1 && b == 3)
{
Send("{ENTER}");
Send("{TAB}");
}
?
qkuh is offline  
Old 07/01/2012, 23:15   #5
 
elite*gold: 0
Join Date: May 2012
Posts: 8
Received Thanks: 2
Hey,

Ist eigentlich ganz einfach du musst beide While Schleifen verschmelzen
k1u1337 is offline  
Old 07/01/2012, 23:15   #6
 
xNopex's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 827
Received Thanks: 471
Code:
while(a==1 || b==3)
{
    if(a==1)
    {
        Send("{ENTER}");
    }
    if(b==3)
    {
        Send("{TAB}");
    }
}
???
xNopex is offline  
Old 07/01/2012, 23:19   #7
 
Naworia's Avatar
 
elite*gold: 12
Join Date: Aug 2011
Posts: 455
Received Thanks: 418
I don't want that in same loop. I want parallel.
Example:


Code:
While(a == 1)
{
  Send("{ENTER}");
  Thread.Sleep(1000);
}

While(b == 3)
{
  Send("{TAB}");
  Thread.Sleep(15000);
}
As you saw, first loop must wait 1 sec, but second loop must wait 15 sec.
Naworia is offline  
Old 07/01/2012, 23:58   #8


 
MrSm!th's Avatar
 
elite*gold: 7110
Join Date: Jun 2009
Posts: 28,902
Received Thanks: 25,407
Arrow C/C++ -> .NET Languages

#moved

@Topic: Use threads.
MrSm!th is offline  
Old 07/02/2012, 00:00   #9


 
Jeoni's Avatar
 
elite*gold: 966
Join Date: Apr 2010
Posts: 1,105
Received Thanks: 681
/Edit: MrSmith said it first
Use multithreading.
Code:
Void InitializeLoops()
{
Thread Loop1Thread = new Thread(new ThreadStart(LoopFunc1));
Thread Loop2Thread = new Thread(new ThreadStart(LoopFunc2));

Loop1Thread.Start();
Loop2Thread.Start();
}

void LoopFunc1()
{
While(a == 1)
{
  Send("{ENTER}");
  Thread.Sleep(1000);
}
}

void LoopFunc2()
{
While(b == 3)
{
  Send("{TAB}");
  Thread.Sleep(15000);
}
}
I don't know if it's working this way, but you can give it a try. Maybe there are mistakes, because I made this out of my head.
Jeoni is offline  
Old 07/02/2012, 00:23   #10
 
Naworia's Avatar
 
elite*gold: 12
Join Date: Aug 2011
Posts: 455
Received Thanks: 418
Thank you for your both replies. I used them but i can't create a "Thread" for timer1_Tick.
It says an error about "No overload".
I sued this code :
Code:
Thread Loop1Thread = new Thread(new ThreadStart(timer1_Tick));
Naworia is offline  
Old 07/02/2012, 02:36   #11
 
Mashkin's Avatar
 
elite*gold: 44
Join Date: May 2010
Posts: 2,053
Received Thanks: 1,747
Quote:
Originally Posted by Naworia View Post
Thank you for your both replies. I used them but i can't create a "Thread" for timer1_Tick.
It says an error about "No overload".
I sued this code :
Code:
Thread Loop1Thread = new Thread(new ThreadStart(timer1_Tick));
Please give more details on errors next time.

I guess the error occurs because the Tick event handlers commonly take two arguments:
Code:
void Timer1_Tick(Object sender, EventArgs e);
There is no candidate taking no arguments.

You will have to pass all parameters for the threaded method in one object (when calling the Start() method). However, you can also overload the Timer1_Tick method to handle no arguments (or one object which could include an array of arguments).

Easiest way would be a method simply calling the Timer1_Tick method.

Code:
public void Timer1_Tick(Object sender, EventArgs e)
{
 ... your original Tick method
}

public void Call_Timer1_Tick()
{
    this.Timer1_Tick(null, null);
}
Watch out: untested.
Mashkin is offline  
Thanks
1 User
Old 07/02/2012, 03:39   #12
 
Naworia's Avatar
 
elite*gold: 12
Join Date: Aug 2011
Posts: 455
Received Thanks: 418
Thank you man. i solved <3
Naworia is offline  
Reply


Similar Threads Similar Threads
Parallel Kingdom
10/14/2011 - Browsergames - 0 Replies
Servus , schon mal jemand was über das Spiel gehört. Gibts auf Handys und wurde jetzt als Browsergame umgesetzt. Hab da schon ein wenig rumgebastelt und einige erfolge erzielt. Problem ist nur, die Arbeiten mit Googlemaps. Sie brauchen den Standort im Spiel um zu wissen wo man im game Startet. Das dumme is nur wenn mann über einen Proxy einen Account erstellen will geht es nicht weil er keine Position findet wo der Char starten kann. Gibts es Proxys die nicht Anonym sind ?
# PAE parallel zu IPFW #
12/26/2010 - Metin2 Private Server - 0 Replies
So ich hab hier ein technisches Problem. Ich hab jetzt nun beide Kernel Kompiliert PAE und IPFW. Nund hab ich ein Problem. Entweder ich installier den PAE dan geht die Firewall nicht mehr Bei nur PAE und ipfw list
[MYSRO]Db Bot V0.8 is Not Looping
08/14/2010 - SRO Private Server - 3 Replies
my problem is bot is not looping as i want it stays near the storage i did the tool for the loop it started looping and stopped near the storage again. i think its proxlem about Storage's x,y. can some1 fix it? Thanks.
Looping patch
06/16/2010 - Grand Chase Philippines - 3 Replies
Help please. Paulit ulit pinapatch char_script and script ko.
Bot looping problem
04/24/2007 - Silkroad Online - 1 Replies
I have a config set up for my farmer but every time it gets to the bandit archer place it return scrolls , then goes and repairs then goes back. Then it will get hit by like 2 monsters then start to return scroll again. And I unchecked the durability "go back to town" options and it still did it. What did I do wrong. And does anyone have a configuration that i could use for my lvl 32 pure str blader that works good in a loop?



All times are GMT +1. The time now is 09:18.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.