By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,646 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,646 IT Pros & Developers. It's quick & easy.

receiving the data from serial port and show a new screen (C# .net micro framework)

P: 2
Hi,

I am creating an interface which contains the listbox(C# .net micro framework). When the listbox item is seletected, it will send a character to the serial port and show a "send command" screen. When receiving the data from serial port, it will show another "receive command" screen. The problem i am facing now is the program not able to show out the "receive command" screen. The following is some part of the code:

public class MainMenu : PresentationWindow
{
public MainMenu(myApplication app)
: base(app)
{
System.Threading.Thread serialThread = new
System.Threading.Thread(updateData);
serialThread.Start();
// do something here
}

public void updateData()
{
while (true)
{
importData();
}
}

int bytecount = 0;

public int importData()
{
UTF8Encoding enc = new UTF8Encoding();
byte[] buffer = new byte[32];
count = serialPort.Read(buffer, 0, buffer.Length, 1000);

int count;
if (count > 0)
{
serialPort.Write(buffer, 0, count);
bytecount += count;
new WarningScreen(myApp);
}
return byteCount.ToString();
}
}

public class WarningScreen : PresentationWindow
{
public WarningScreen(myApplication app)
: base(app)
{
// do something here...
}
}

I think maybe is because the while loop part cause the problem, but i don't
have any idea to solve it. Is there anyone can help me?

Thanks,
Celine
Oct 4 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.