Click here to Skip to main content
15,889,176 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to create a tool item dropdown menu with C#? Pin
Christian Graus8-Sep-09 12:31
protectorChristian Graus8-Sep-09 12:31 
QuestionOdd Visual Studio 2005 behaviour when adding Object Data Source [modified] Pin
Martijn Boeker8-Sep-09 12:10
Martijn Boeker8-Sep-09 12:10 
QuestionSubreports Pin
mbangh8-Sep-09 12:05
mbangh8-Sep-09 12:05 
AnswerRe: Subreports Pin
Mycroft Holmes8-Sep-09 15:59
professionalMycroft Holmes8-Sep-09 15:59 
QuestionNetworking problems. Pin
CRAZYCRICKET2258-Sep-09 9:19
CRAZYCRICKET2258-Sep-09 9:19 
GeneralRe: Networking problems. Pin
harold aptroot8-Sep-09 10:40
harold aptroot8-Sep-09 10:40 
AnswerRe: Networking problems. Pin
Luc Pattyn8-Sep-09 14:08
sitebuilderLuc Pattyn8-Sep-09 14:08 
GeneralRe: Networking problems. Pin
CRAZYCRICKET2258-Sep-09 21:36
CRAZYCRICKET2258-Sep-09 21:36 
Thanks for the answers but I didn't understand some:
first of all how can i make sure a thread is being closed automatically?

second, I removed all the GC.collect, the Thread.abort and the code looks fine, I'll show you a piece:
Server:

doClientMove(){
timer = 15;
Random questionSend = new Random();
string qID = "ID:" + questionSend.Next(1, 5).ToString();
q = new Question(int.Parse(qID.Substring(qID.IndexOf(":") + 1, qID.Length - (qID.IndexOf(":") + 1))),host);
host.c.sendObject(1, q._questionString + "$" + q._questionAnswer + "$" + q._questionMis1 + "$" + q._questionMis2 + "$" + q._questionMis3 + "$" + q._rightAnswer + "$");
}

it creates a question , sends it to Client and wait to get back a sign to open a question by itself.


The Question:

Thread for the server constructer;

private void f1()
{
while (1 == 1)
{
if (_gameStart == 1)
{
int i = 15;
while (i > 0)
{
a.Text = i.ToString();
Thread.Sleep(1000);
i--;
host.c.sendObject(1,"PSYDOWN");
timer--;

}
_gameStart = 0;
this.Close();
}
}
}

Thread for the client constructer
private void f2()
{
while (1 == 1)
{
if (_gameStart == 1)
{
int i = 15;
while (i > 0)
{
a.Text =timer.ToString();
i =timer;

//a.Text = i.ToString();
//Thread.Sleep(1000);
//i--;
}

_gameStart = 0;
this.Close();
}
}
}

//server listening until the timer is over.
public void listening()
{
IFormatter form = new BinaryFormatter();
object geting = null;
ntStr.Flush();
string move;
while (timer>0)
{

if (ntStr.DataAvailable)
{

geting = form.Deserialize(ntStr);
move = (string)geting;
if (move == "PSYDOWN")
{
timer--;
}

}
}

}



What's wrong? Maybe I shouldn't share a timer? just open to each form a diffrent timer and hope it will sync?

Please , I am stuck ; what can i do??
GeneralRe: Networking problems. Pin
CRAZYCRICKET2259-Sep-09 0:26
CRAZYCRICKET2259-Sep-09 0:26 
GeneralRe: Networking problems. Pin
Luc Pattyn9-Sep-09 12:29
sitebuilderLuc Pattyn9-Sep-09 12:29 
QuestionC# Pin
aayshasid8-Sep-09 9:18
aayshasid8-Sep-09 9:18 
AnswerRe: C# Pin
Not Active8-Sep-09 9:22
mentorNot Active8-Sep-09 9:22 
AnswerRe: C# Pin
Manas Bhardwaj8-Sep-09 9:26
professionalManas Bhardwaj8-Sep-09 9:26 
AnswerRe: C# Pin
Christian Graus8-Sep-09 11:34
protectorChristian Graus8-Sep-09 11:34 
QuestionRunning C# App over Network Pin
mbangh8-Sep-09 8:41
mbangh8-Sep-09 8:41 
AnswerRe: Running C# App over Network Pin
Not Active8-Sep-09 9:19
mentorNot Active8-Sep-09 9:19 
AnswerRe: Running C# App over Network Pin
DaveyM698-Sep-09 9:38
professionalDaveyM698-Sep-09 9:38 
GeneralRe: Running C# App over Network Pin
mbangh8-Sep-09 10:24
mbangh8-Sep-09 10:24 
GeneralRe: Running C# App over Network Pin
DaveyM698-Sep-09 10:26
professionalDaveyM698-Sep-09 10:26 
AnswerRe: Running C# App over Network Pin
darkelv8-Sep-09 15:31
darkelv8-Sep-09 15:31 
AnswerRe: Running C# App over Network Pin
Harvey Saayman8-Sep-09 20:52
Harvey Saayman8-Sep-09 20:52 
Questionc# help Pin
liveinweb2.08-Sep-09 8:14
liveinweb2.08-Sep-09 8:14 
AnswerRe: c# help Pin
dan!sh 8-Sep-09 8:29
professional dan!sh 8-Sep-09 8:29 
AnswerRe: c# help Pin
Christian Graus8-Sep-09 11:37
protectorChristian Graus8-Sep-09 11:37 
AnswerRe: c# help Pin
April Fans22-Sep-09 19:11
April Fans22-Sep-09 19:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.