Click here to Skip to main content
15,914,500 members
Home / Discussions / C#
   

C#

 
GeneralRe: Logging on Removable Device Pin
wenlong8822-Oct-10 17:24
wenlong8822-Oct-10 17:24 
AnswerRe: Logging on Removable Device Pin
_Erik_22-Oct-10 4:20
_Erik_22-Oct-10 4:20 
GeneralRe: Logging on Removable Device Pin
Dave Kreskowiak22-Oct-10 13:27
mveDave Kreskowiak22-Oct-10 13:27 
GeneralRe: Logging on Removable Device Pin
_Erik_22-Oct-10 22:34
_Erik_22-Oct-10 22:34 
GeneralRe: Logging on Removable Device Pin
Dave Kreskowiak23-Oct-10 7:46
mveDave Kreskowiak23-Oct-10 7:46 
GeneralRe: Logging on Removable Device Pin
wenlong8822-Oct-10 17:22
wenlong8822-Oct-10 17:22 
QuestionReference a method from one user control from within another user control? Pin
Ian Durward21-Oct-10 15:17
Ian Durward21-Oct-10 15:17 
AnswerRe: Reference a method from one user control from within another user control? [modified] Pin
Karthik. A21-Oct-10 16:46
Karthik. A21-Oct-10 16:46 
AnswerRe: Reference a method from one user control from within another user control? Pin
Ravi Bhavnani21-Oct-10 17:19
professionalRavi Bhavnani21-Oct-10 17:19 
AnswerRe: Reference a method from one user control from within another user control? Pin
_Erik_22-Oct-10 4:50
_Erik_22-Oct-10 4:50 
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 

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.