@Jon wrote:
Apologies if this is a basic programming question. Typically when moving an object in Rhino, the AddRhinoObject event is raised once. However, if I reference a class field inside the event handler, the event is raised twice (see below). How can I prevent this from happening?
internal class RhinoListenerClass { private Task listener; private List<double> data; internal RhinoListenerClass() { data = new List<double>(); listener = RhinoListener(); } private async Task RhinoListener() { await Task.Run(() => { RhinoDoc.AddRhinoObject += (s, e) => { Eto.Forms.MessageBox.Show("AddRhinoObject"); var d = data; // this causes the event to be raised twice }; }); } }
Thanks
Jon
Posts: 1
Participants: 1