-
December 4th, 2010, 02:38 AM
#1
Migrating to a Windows Form Application
I’ve managed to put together a Windows Console Application from examples on MSDN and the Internet at large. As a system programmer (PERL, KSH, microcontrollers, etc.) I am having difficulty migrating the code to a Windows Form Application. What are some good resources to help in this migration process. The project I am working on is and Arduino board with an Ethernet port. The Arduino microcontroller will send UDP data to a PC that will receive the message and display the data in a text box. The console application I have does exactly what I want, I just need to migrate it to a Windows Form Application.
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace udpasync
{
class Program
{
static UdpClient usck;
static void recv(IAsyncResult res)
{
IPEndPoint remote = new IPEndPoint(IPAddress.Any, 0);
byte[] data = usck.EndReceive(res, ref remote);
// do something with data received from remote
Console.WriteLine(remote.Address.ToString() + ": " + Encoding.ASCII.GetString(data));
// get next packet
usck.BeginReceive(recv, null);
}
static void Main(string[] args)
{
usck = new UdpClient(514);
Console.WriteLine("waiting for packets, hit enter to stop");
usck.BeginReceive(new AsyncCallback(recv), null);
Console.ReadLine();
usck.Close();
}
}
}
Thanks,
J
-
December 4th, 2010, 05:48 AM
#2
Re: Migrating to a Windows Form Application
what should the application exacly look like? should it have just a single button or something... what are you having problems with?
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
December 6th, 2010, 05:18 AM
#3
Re: Migrating to a Windows Form Application
The initial Windows form program would just a single text box (textBox1) that will write a received on a UDP port. Later I plan on parsing the received data to write to various different text boxes. Unlike the console application where all the code is contained on a single file. I am having troubled breaking the code up to be initialized in the program.cs and called from the form1.cs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|