Events

Jan 25, 2012 at 7:19 PM

Is it possible to handle events?

Coordinator
Jan 25, 2012 at 8:38 PM
On 1/25/2012 3:19 PM, LukeTerry wrote:
> Is it possible to handle events?

AFAIK it works.
Coordinator
Jan 26, 2012 at 8:10 AM
Singlecast events should work, not sure about multicast, but please try and let us know..

On Wed, Jan 25, 2012 at 9:38 PM, kudzu <notifications@codeplex.com> wrote:

From: kudzu

On 1/25/2012 3:19 PM, LukeTerry wrote:
> Is it possible to handle events?

AFAIK it works.

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jan 26, 2012 at 6:17 PM

I tried running this code:

private EventTester et;
protected override void BeforeRun()
{
     et = new EventTester();
     et.ObjChanged += new EventHandler(et_ObjChanged);
}

void et_ObjChanged(object sender, EventArgs e)
{
     Console.WriteLine("Events Work! (x = {0})", et.x);
     Console.ReadLine();
}

protected override void Run()
{
     string input = Console.ReadLine();
     int d = 0;
     int.TryParse(input, out d);
     et.x = d;
}


Class EventTester is just a class with an x property defined and a ObjChanged event.

However it throws this error:

Error 1 Natie code encountered, plug required. Please see http://cosmos.codeplex.com/wikipage?title=Plugs).System.Void  System.Threading.Interlocked._CompareExchange(System.TypedReference, System.TypedReference, System.Object). Called from :System.EventHandler CompareExchange[EventHandler](System.EventHandler ByRef, System.EventHandler, System.EventHandler)Void add_ObjChanged(System.EventHandler)Void BeforeRun()Void BeforeRun()

   at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug, Object sourceItem) in c:\Documents and Settings\User\My Documents\Archives\cosmos-87118\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 815   at Cosmos.IL2CPU.ILScanner.ScanQueue() in c:\Documents and Settings\User\My Documents\Archives\cosmos-87118\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 955   at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) in c:\Documents and Settings\User\My Documents\Archives\cosmos-87118\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 316   at Cosmos.Build.MSBuild.IL2CPUTask.Execute() in c:\Documents and Settings\User\My Documents\Archives\cosmos-87118\source2\Build\Cosmos.Build.MSBuild\IL2CPUTask.cs:line 249 C:\Program Files\MSBuild\Cosmos\Cosmos.targets 32 10 EventTestBoot.

Coordinator
Jan 27, 2012 at 8:00 AM
you're doing multicast, migt not be working..


On Thu, Jan 26, 2012 at 7:18 PM, lukeTerry <notifications@codeplex.com> wrote:

From: lukeTerry

I tried running this code:

private EventTester et;
protected override void BeforeRun()
{
     et = new EventTester();
     et.ObjChanged += new EventHandler(et_ObjChanged);
}

void et_ObjChanged(object sender, EventArgs e)
{
     Console.WriteLine("Events Work! (x = {0})", et.x);
     Console.ReadLine();
}

protected override void Run()
{
     string input = Console.ReadLine();
     int d = 0;
     int.TryParse(input, out d);
     et.x = d;
}


Class EventTester is just a class with an x property defined and a ObjChanged event.

However it throws this error:

Error 1 Natie code encountered, plug required. Please see http://cosmos.codeplex.com/wikipage?title=Plugs).System.Void System.Threading.Interlocked._CompareExchange(System.TypedReference, System.TypedReference, System.Object). Called from :System.EventHandler CompareExchange[EventHandler](System.EventHandler ByRef, System.EventHandler, System.EventHandler)Void add_ObjChanged(System.EventHandler)Void BeforeRun()Void BeforeRun()

at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug, Object sourceItem) in c:\Documents and Settings\User\My Documents\Archives\cosmos-87118\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 815 at Cosmos.IL2CPU.ILScanner.ScanQueue() in c:\Documents and Settings\User\My Documents\Archives\cosmos-87118\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 955 at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) in c:\Documents and Settings\User\My Documents\Archives\cosmos-87118\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 316 at Cosmos.Build.MSBuild.IL2CPUTask.Execute() in c:\Documents and Settings\User\My Documents\Archives\cosmos-87118\source2\Build\Cosmos.Build.MSBuild\IL2CPUTask.cs:line 249 C:\Program Files\MSBuild\Cosmos\Cosmos.targets 32 10 EventTestBoot.

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Developer
Jan 27, 2012 at 1:49 PM

@mterwoord: What would it take to implement multi-cast events? As OForms (my window system + my version of winforms), uses them heavily for dispatching clicks, mouse movements, and key presses. (I also need proper interface support, as my controls & the window class implement the IDisposable interface, and that method isn't getting emitted.)

Coordinator
Jan 27, 2012 at 1:53 PM
multicast events, not sure. can someone test singlecast events for me>?
code:
Action MyEvent = new Action(delegate{Console.WriteLine("Hello");});
MyEvent();
If that works, the compiler needs to be fixed for the multicast delegates..


On Fri, Jan 27, 2012 at 2:49 PM, blah38621 <notifications@codeplex.com> wrote:

From: blah38621

@mterwoord: What would it take to implement multi-cast events? As OForms (my window system + my version of winforms), uses them heavily for dispatching clicks, mouse movements, and key presses. (I also need proper interface support, as my controls & the window class implement the IDisposable interface, and that method isn't getting emitted.)

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jan 29, 2012 at 11:17 PM

Oh right, that would explain why it isn't working then, but how do I use singlecast then? Because I would of assumed it would be using "=" rather than "+=", but it threw an error for that also. Thanks, Luke.

Coordinator
Jan 30, 2012 at 8:04 AM
"public event EventHandler MyEvent" is by defintiion multicast
use public EventHandler MyEvent, and you can use MyEvent = delegate{};

On Mon, Jan 30, 2012 at 12:17 AM, lukeTerry <notifications@codeplex.com> wrote:

From: lukeTerry

Oh right, that would explain why it isn't working then, but how do I use singlecast then? Because I would of assumed it would be using "=" rather than "+=", but it threw an error for that also. Thanks, Luke.

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com