I first wanted to thank you for creating this library, it has been extraordinarily helpful.
I'm trying the create a simulator that inherits from the simulation class. However, this new simulator is in c++. Everything almost works. The problem is that there is no equivalent statement for yield break. I created an iterator, but it does not work as intended. My processes will each run once, while they should run endlessly. Has anyone implemented a subclass of simulation in c++ before? How should I deal with the enumerators?
Thanks for your help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I presume the problem is not the subclassing, but rather creating the ProcessSteps delegate or overiding Process.GetProcessSteps(). Unfortunately, as far as I can see, C# is the only Visual Studio language that supports a "yield return/break" statement.
There's a bunch of extra plumbing behind the scenes that the C# compiler actually sets up when you use the "yield" statement. Open the BarberShop.exe program in the MSIL decompiler and look at the Barber, Customer, or Shop classes and you'll see a generated inner-class named d__0. This is something the compiler creates to support maintaining the state of the iterator method. In C++, since there's no "yield" statement, you'd need to write an IEnumerator<Task> implementation yourself, which would be returned by your ProcessSteps delegate (or from the Process.GetProcessSteps method). Certainly more work than in C#, but it should be possible.
— Eric —
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I first wanted to thank you for creating this library, it has been extraordinarily helpful.
I'm trying the create a simulator that inherits from the simulation class. However, this new simulator is in c++. Everything almost works. The problem is that there is no equivalent statement for yield break. I created an iterator, but it does not work as intended. My processes will each run once, while they should run endlessly. Has anyone implemented a subclass of simulation in c++ before? How should I deal with the enumerators?
Thanks for your help.
I presume the problem is not the subclassing, but rather creating the ProcessSteps delegate or overiding Process.GetProcessSteps(). Unfortunately, as far as I can see, C# is the only Visual Studio language that supports a "yield return/break" statement.
There's a bunch of extra plumbing behind the scenes that the C# compiler actually sets up when you use the "yield" statement. Open the BarberShop.exe program in the MSIL decompiler and look at the Barber, Customer, or Shop classes and you'll see a generated inner-class named d__0. This is something the compiler creates to support maintaining the state of the iterator method. In C++, since there's no "yield" statement, you'd need to write an IEnumerator<Task> implementation yourself, which would be returned by your ProcessSteps delegate (or from the Process.GetProcessSteps method). Certainly more work than in C#, but it should be possible.
— Eric —