Jump to content
|Topic||Stats||Last action by|
|Microsoft is Apple?||
|Jimquisition (Feb. 23) - The Old 'How Long Should Games Be?' Debate||
|New white & gold PS4 controller||
|Mac OS X Isn’t Safe Anymore: The Crapware / Malware Epidemic Has Begun||
|Windows 10 Technical Preview||
Posted 08 November 2012 - 23:10
Posted 08 November 2012 - 23:16
Put that code in its own method and pass the method as a delegate to a BackgroundWorker. There are many more options for threading in .NET but that's probably the simplest one here.
thanks everyone and yes it is in an endless loop how do I put it in its own thread?
Posted 09 November 2012 - 13:48
How does it not work? What do you expect it to do? Do you have a client as well? A listener is just that, a listener, it listens to incoming connections. You need one instance of your app that acts as the server and one (or multiple others) that act as the client. There's a link to an example TcpClient in that same tutorial page for TcpListener. Read up on tcp connections, how to establish a connection, how to pass messages around, how to close the connection.
"A lot of ifs" is a terrible way of going about this btw. What would you do for a 10x10 tic-tac-toe? Code 100 if-elses? What if you wanted to support multiple different sizes? If you don't know about lists and loops I don't think there's any way you're going to add multiplayer functionality. Start one step at a time.
Posted 09 November 2012 - 18:35
Posted 10 November 2012 - 13:22
Posted 10 November 2012 - 17:30
Posted 10 November 2012 - 19:01
You're not allowed to update the UI from any other thread than the UI thread. Use the Invoke (synchronous) or BeginInvoke (asynchronous) method of the main form to pass UI updates (as delegates) from a background thread.
Posted 10 November 2012 - 19:20
Posted 10 November 2012 - 19:49
Of course, googling any of the terms I mentionned will return you hundreds of useful results.
Is there a sample of that somewhere?
Posted 10 November 2012 - 20:05
Posted 10 November 2012 - 21:03
"Me" is a reference to the current object, for instance if your code is inside your main Form class (like most tutorials assume), then "Me" is a reference to the Form object, which has an Invoke and a BeginInvoke method. Since I suppose you segregated your background thread code to another class, you'll have to pass it a reference to the Form object in order to invoke any methods of the Form from it. Alternatively, you could simply bring that code back to the main Form class and you'd be able to use "Me" to reference to Form then.
I dont get any of the codes they all use me.whatever and that always causes an error
Posted 10 November 2012 - 21:50
Posted 10 November 2012 - 22:00
Posted 11 November 2012 - 00:50