Forum C# (Ask) Multi Thread Console Window

(Ask) Multi Thread Console Window

Postby wbsaputra » February 10th, 2011, 2:58 am

Any sample code how to create multiple thread & console window for client .Net? :)
wbsaputra
Paid Member
 
Posts: 150
Joined: June 29th, 2010, 4:38 pm

Re: (Ask) Multi Thread Console Window

Postby Oliver » February 18th, 2011, 3:14 pm

Don't understand?
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: (Ask) Multi Thread Console Window

Postby wbsaputra » February 21st, 2011, 9:26 am

i try create ai player with client.net, and done with 1 application for 1 ai player, but i need to control multiple ai player in 1 app, so i think i must create form with multiple player so i can choose which ai player id and which room id to connect to.
Each ai player has 1 console window so i can view their activity.
This similiar like player io test development server which every room has different console in 1 form application.
How could you do that, i confuse about connecting console and a form because there are in separate thread, cross thread error appear. Any advice link or sample code would be grateful. :D

Btw i began creating payment module, i will use payvault and go to paid, I work around in admin panel try to create payvault item, do i need move every player object item to payvault table where player can buy those in payvault?
Because for now i store every player item object in playerobject table.
wbsaputra
Paid Member
 
Posts: 150
Joined: June 29th, 2010, 4:38 pm

Re: (Ask) Multi Thread Console Window

Postby Oliver » February 21st, 2011, 10:21 pm

i try create ai player with client.net, and done with 1 application for 1 ai player, but i need to control multiple ai player in 1 app, so i think i must create form with multiple player so i can choose which ai player id and which room id to connect to.


Okay. Sure.

How could you do that, i confuse about connecting console and a form because there are in separate thread, cross thread error appear. Any advice link or sample code would be grateful.


The player.io client runs in whatever thread calls into it. The async callbacks are however executed by threads in the .NET thread pool.

WinForms has some nasty issues about updating the ui from another thread, but you can get around it with the "control.Invoke" method. See more here: http://stackoverflow.com/questions/6615 ... hread-in-c

We use it like so:

Code: Select all
form.BeginInvoke((MethodInvoker)delegate{
   // ... access form here
});


Btw i began creating payment module, i will use payvault and go to paid, I work around in admin panel try to create payvault item, do i need move every player object item to payvault table where player can buy those in payvault?
Because for now i store every player item object in playerobject table.


The only objects you need to have in the PayVault Items table are objects you intend to sell for real money or virtual currency.

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: (Ask) Multi Thread Console Window

Postby wbsaputra » February 22nd, 2011, 4:10 am

Thank you, i have same thought about invoke method, but not so sure. Now i have good clue.
About payvault, i create card game like texas holdem, now i have player object chips item, do i have to move all to payvault table and change my game code?(because now all player chips is calculating and stored in player object table)
or i have to create some virtual currency eg. Gold then each player must buy payvault gold and transfer to chips.
which is better?
wbsaputra
Paid Member
 
Posts: 150
Joined: June 29th, 2010, 4:38 pm

Re: (Ask) Multi Thread Console Window

Postby Oliver » February 23rd, 2011, 8:55 pm

You'll probably make a few payvault items like "500 chips", "200 chips" and "100 chips", that your users can buy. Then when they've bought it, just convert the item into chips on the player object.
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am


Return to C#



cron