Click here to Skip to main content
15,886,362 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
Questioncustome disassembler for biztalk Pin
sweetdecember1029-Mar-07 0:14
sweetdecember1029-Mar-07 0:14 
AnswerRe: custome disassembler for biztalk Pin
JoeSharp9-Mar-07 0:47
JoeSharp9-Mar-07 0:47 
Questionhelp me Pin
nandhusivakumar8-Mar-07 23:49
nandhusivakumar8-Mar-07 23:49 
AnswerRe: help me Pin
Mircea Puiu8-Mar-07 23:58
Mircea Puiu8-Mar-07 23:58 
Questionbrowse path with FolderBrowserDialog Pin
mhadamji8-Mar-07 12:12
mhadamji8-Mar-07 12:12 
QuestionHow to have multithread on a socket (one thread read, other thread write) Pin
Spulit8-Mar-07 6:27
Spulit8-Mar-07 6:27 
AnswerRe: How to have multithread on a socket (one thread read, other thread write) Pin
led mike8-Mar-07 7:31
led mike8-Mar-07 7:31 
GeneralRe: How to have multithread on a socket (one thread read, other thread write) Pin
Spulit8-Mar-07 7:39
Spulit8-Mar-07 7:39 
Here is a simplified version ("buffer" is protected by a mutex). The receiving thread is a BackgroundWorker (readSocket method) which is fired over and over again until the thread is cancelled.

SocketRW::SocketRW(unsigned short int port_)
{
Port = port_;
socket = gcnew Socket(AddressFamily::InterNetwork,SocketType::Dgram,ProtocolType::Udp);
socket->Bind(gcnew IPEndPoint(IPAddress::Any, Port));
buffer = gcnew array<unsigned char="">(512);
worker = gcnew BackgroundWorker;
worker->WorkerSupportsCancellation = true;
worker->DoWork += gcnew DoWorkEventHandler(&(SocketRW::readSocket));
worker->RunWorkerCompleted += gcnew RunWorkerCompletedEventHandler(&(SocketRW::fireMsg));
}

void SocketRW::readSocket(Object^ sender, DoWorkEventArgs^ e)
{
int bytesrec;

try{
Array::Clear(buffer, 0, buffer->Length);
bytesrec = socket->Receive(buffer);
}
catch(Exception ^e)
{
// Whenever the other thread sends bytes through this socket, the Receive method above throws an System.Net.Sockets.SocketException with the message I posted above.
}
e->Result = bytesrec;
}

void SocketRW::fireMsg(Object^ sender, RunWorkerCompletedEventArgs^ e)
{
// do stuff with the message in "buffer"
// Need this in order to update the GUI with the correct thread
if (!e->Cancelled)
worker->RunWorkerAsync();
}
GeneralRe: How to have multithread on a socket (one thread read, other thread write) Pin
pbraun8-Mar-07 9:18
pbraun8-Mar-07 9:18 
GeneralRe: How to have multithread on a socket (one thread read, other thread write) Pin
Spulit8-Mar-07 14:19
Spulit8-Mar-07 14:19 
GeneralRe: How to have multithread on a socket (one thread read, other thread write) Pin
led mike9-Mar-07 4:30
led mike9-Mar-07 4:30 
QuestionHow multiple instances listen to a UDP socket Pin
nsutanto8-Mar-07 5:08
nsutanto8-Mar-07 5:08 
QuestionProcess component and redirecting standard output Pin
SquidDigger8-Mar-07 4:09
SquidDigger8-Mar-07 4:09 
QuestionBreakpoint will not currently be hit Pin
TeachesOfPeaches7-Mar-07 11:03
TeachesOfPeaches7-Mar-07 11:03 
AnswerRe: Breakpoint will not currently be hit Pin
Vasudevan Deepak Kumar7-Mar-07 11:15
Vasudevan Deepak Kumar7-Mar-07 11:15 
GeneralRe: Breakpoint will not currently be hit Pin
TeachesOfPeaches7-Mar-07 12:42
TeachesOfPeaches7-Mar-07 12:42 
AnswerRe: Breakpoint will not currently be hit Pin
kubben7-Mar-07 12:57
kubben7-Mar-07 12:57 
GeneralRe: Breakpoint will not currently be hit Pin
TeachesOfPeaches8-Mar-07 5:17
TeachesOfPeaches8-Mar-07 5:17 
AnswerRe: Breakpoint will not currently be hit Pin
Dave Kreskowiak8-Mar-07 4:32
mveDave Kreskowiak8-Mar-07 4:32 
GeneralRe: Breakpoint will not currently be hit Pin
TeachesOfPeaches8-Mar-07 9:47
TeachesOfPeaches8-Mar-07 9:47 
GeneralRe: Breakpoint will not currently be hit Pin
Vasudevan Deepak Kumar9-Mar-07 6:19
Vasudevan Deepak Kumar9-Mar-07 6:19 
GeneralRe: Breakpoint will not currently be hit Pin
TeachesOfPeaches9-Mar-07 11:54
TeachesOfPeaches9-Mar-07 11:54 
QuestionWebConfig Section for .NET Framework 3.0 Pin
Vasudevan Deepak Kumar7-Mar-07 10:47
Vasudevan Deepak Kumar7-Mar-07 10:47 
QuestionSockets issue, how to listen to UDP socket for multiple instances Pin
nsutanto7-Mar-07 10:36
nsutanto7-Mar-07 10:36 
QuestionMultithreading Local Variables Pin
MikeMarq7-Mar-07 8:09
MikeMarq7-Mar-07 8:09 

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.