JumpyNET
Centurion
- Joined
- Apr 4, 2005
- Messages
- 196
I and also the translator on developerfusion have trouble translating the following lines of code to VB.NET. I hope you guys can help me out.
[CS]
operation.Post(new SendOrPostCallback(delegate(object state)
{
EventHandler handler = SomethingHappened;
if(handler != null)
{
handler(this, EventArgs.Empty);
}
}), null);
operation.OperationCompleted();[/CS]
And just in case here is the whole code that I am trying to translate:
[CS]
using System;
using System.Threading;
using System.ComponentModel;
namespace SynchronizationContextExample
{
public class MySynchronizedClass
{
private Thread workerThread;
private AsyncOperation operation;
public event EventHandler SomethingHappened;
public MySynchronizedClass()
{
operation = AsyncOperationManager.CreateOperation(null);
workerThread = new Thread(new ThreadStart(DoWork));
workerThread.Start();
}
private void DoWork()
{
operation.Post(new SendOrPostCallback(delegate(object state)
{
EventHandler handler = SomethingHappened;
if(handler != null)
{
handler(this, EventArgs.Empty);
}
}), null);
operation.OperationCompleted();
}
}
}
[/CS]
[CS]
operation.Post(new SendOrPostCallback(delegate(object state)
{
EventHandler handler = SomethingHappened;
if(handler != null)
{
handler(this, EventArgs.Empty);
}
}), null);
operation.OperationCompleted();[/CS]
And just in case here is the whole code that I am trying to translate:
[CS]
using System;
using System.Threading;
using System.ComponentModel;
namespace SynchronizationContextExample
{
public class MySynchronizedClass
{
private Thread workerThread;
private AsyncOperation operation;
public event EventHandler SomethingHappened;
public MySynchronizedClass()
{
operation = AsyncOperationManager.CreateOperation(null);
workerThread = new Thread(new ThreadStart(DoWork));
workerThread.Start();
}
private void DoWork()
{
operation.Post(new SendOrPostCallback(delegate(object state)
{
EventHandler handler = SomethingHappened;
if(handler != null)
{
handler(this, EventArgs.Empty);
}
}), null);
operation.OperationCompleted();
}
}
}
[/CS]
Last edited: