Click here to Skip to main content
15,900,906 members
Home / Discussions / C#
   

C#

 
GeneralRe: Reference a method from one user control from within another user control? Pin
Ian Durward22-Oct-10 8:18
Ian Durward22-Oct-10 8:18 
GeneralRe: Reference a method from one user control from within another user control? Pin
_Erik_22-Oct-10 23:39
_Erik_22-Oct-10 23:39 
QuestionGWT-RPC call from c# .net (google keywords tool external) help Pin
sodevrom21-Oct-10 14:39
sodevrom21-Oct-10 14:39 
AnswerRe: GWT-RPC call from c# .net (google keywords tool external) help Pin
Luc Pattyn21-Oct-10 15:22
sitebuilderLuc Pattyn21-Oct-10 15:22 
GeneralRe: GWT-RPC call from c# .net (google keywords tool external) help Pin
sodevrom22-Oct-10 4:05
sodevrom22-Oct-10 4:05 
GeneralRe: GWT-RPC call from c# .net (google keywords tool external) help Pin
jobs200120-Dec-10 23:16
jobs200120-Dec-10 23:16 
GeneralRe: GWT-RPC call from c# .net (google keywords tool external) help Pin
jobs200120-Dec-10 23:24
jobs200120-Dec-10 23:24 
QuestionEvent handling Pin
Tichaona J21-Oct-10 5:39
Tichaona J21-Oct-10 5:39 
Last time I used an event handler was to detect when a given track that is being played by the media element had ended, which was not difficult simply because the media element has an event called media ended. (http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.mediaended.aspx[^])

However what if the class your working with don't have events, I am working with the socket class and would like to set an event handler to listen for any incoming connection. So for as you can see from the code below I am using a button click event to trigger the application to begin listneing, which isn't that I want. I would like the application to start listening for in coming connections from the get go. How to I do this:

private void BtnListen_Click(object sender, RoutedEventArgs e)
{
Socket listener = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);

listener.Bind(new IPEndPoint(IPAddress.Any, 2112));
listener.Listen(10);

while (true)
{
Socket socket = listener.Accept();
string receivedValue = string.Empty;


byte[] receivedBytes = new byte[1024];
int numBytes = socket.Receive(receivedBytes);

receivedValue = Encoding.ASCII.GetString(receivedBytes,
0, numBytes);
if (receivedValue.Length < -1)
{
break;
}
else
{
MessageBox.Show(receivedValue);

break;
}
listener.Shutdown(SocketShutdown.Both);
listener.Close();

}

listener.Close();

Another problem I am having is that once the listen button is clicked, the application freezes until it receives something.
}
AnswerRe: Event handling Pin
OriginalGriff21-Oct-10 5:51
mveOriginalGriff21-Oct-10 5:51 
AnswerRe: Event handling Pin
Luc Pattyn21-Oct-10 5:55
sitebuilderLuc Pattyn21-Oct-10 5:55 
AnswerRe: Event handling Pin
_Erik_21-Oct-10 6:05
_Erik_21-Oct-10 6:05 
GeneralRe: Event handling Pin
OriginalGriff21-Oct-10 8:21
mveOriginalGriff21-Oct-10 8:21 
GeneralRe: Event handling Pin
_Erik_21-Oct-10 9:46
_Erik_21-Oct-10 9:46 
GeneralRe: Event handling Pin
OriginalGriff21-Oct-10 9:50
mveOriginalGriff21-Oct-10 9:50 
QuestionX / OK intercetption Pin
neverpleat21-Oct-10 3:08
neverpleat21-Oct-10 3:08 
QuestionString split? Pin
SRKSHOME21-Oct-10 2:55
SRKSHOME21-Oct-10 2:55 
AnswerRe: String split? Pin
Abhinav S21-Oct-10 2:58
Abhinav S21-Oct-10 2:58 
GeneralRe: String split? Pin
SRKSHOME21-Oct-10 3:22
SRKSHOME21-Oct-10 3:22 
GeneralRe: String split? Pin
Abhinav S21-Oct-10 8:30
Abhinav S21-Oct-10 8:30 
AnswerRe: String split? Pin
PIEBALDconsult21-Oct-10 3:11
mvePIEBALDconsult21-Oct-10 3:11 
AnswerRe: String split? Pin
_Erik_21-Oct-10 5:14
_Erik_21-Oct-10 5:14 
GeneralRe: String split? Pin
SRKSHOME21-Oct-10 20:46
SRKSHOME21-Oct-10 20:46 
Questionsomething faster than GetPixel and SetPixel ? Pin
inayathussaintoori21-Oct-10 2:18
inayathussaintoori21-Oct-10 2:18 
AnswerRe: something faster than GetPixel and SetPixel ? Pin
Abhinav S21-Oct-10 2:56
Abhinav S21-Oct-10 2:56 
GeneralRe: something faster than GetPixel and SetPixel ? Pin
inayathussaintoori21-Oct-10 13:12
inayathussaintoori21-Oct-10 13:12 

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.