Hey,
So I am having issues with some of my plugins, specifically votechecker.
The problem
There are 2 webrequests, both can run or only 1 can run.
The problem is the response time might be slow and the callback can yield a result slowly. I have a field called "timesVoted" and gets reset on GetRewardsForThisPlayer.
Once GetRewardsForThisPlayer is called, it resets timesVoted to 0, and both webrequests callbacks could increment it with timesVoted+= votesFromRequest;.
Problem now is, this will get passed by the first webrequest to come back, since they both are not returning at the exact same. How would I wait for both to return their results and then only proceed to give items.
Wait for 2 webrequest to run callbacks and then do something
Discussion in 'Hurtworld Development' started by Pho3niX90, Feb 11, 2016.
-
You would propably need to do what you want to wait for, in the callback of the webrequest.
-
You could use CountdownEvent Class (System.Threading)
If both request need to run you:
var countdown = new CountdownEvent (2);
Fire off both request:
In each request have the callback signal the countdown:
countdown.Signal();
Have another thread kick off your vote update method and the first thing it will call is: -
-
-