{"id":1096,"date":"2021-07-28T20:35:18","date_gmt":"2021-07-28T20:35:18","guid":{"rendered":"https:\/\/www.parametriczoo.com\/?p=1096"},"modified":"2021-07-28T21:36:03","modified_gmt":"2021-07-28T21:36:03","slug":"grasshopper-plugin-event-based-asynchronous-programming-in-c","status":"publish","type":"post","link":"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/","title":{"rendered":"Grasshopper plugin &#038; Event based asynchronous programming in C#"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;3.22.7&#8243;][et_pb_row _builder_version=&#8221;3.22.7&#8243;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;3.22.7&#8243;][et_pb_text _builder_version=&#8221;3.22.7&#8243;]<\/p>\n<p>I am just working on a Grasshopper plugin which requires multi-threading. At the beginning I had some problem with implementing the asynchronized event and expiring the grasshopper solution from another thread. It seams that this topic is already discussed and there are some snipped codes you may find on Rhino forum , however, I could not find a complete implementation of asynchronous programming which uses the\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/programming-guide\/concepts\/async\/\">AsyncCompletedEventArgs\u00a0<\/a>within the Grasshopper component. Today I managed to use Asynchronized operation and I would like to share a few files as template which helps you to put up your code and take advantages of an asynchronous program. Please remember that asnych-programming is useful when you want to avoid the frozen UI or you are working with server side applications in which you need to wait for data to be downloaded or uploaded and also be noted that asynchronous programming does not always make things faster ! So if you are ready let&#8217;s jump into some code..<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_accordion _builder_version=&#8221;3.22.7&#8243;][et_pb_accordion_item title=&#8221;Grasshopper Component&#8221; open=&#8221;off&#8221; _builder_version=&#8221;3.22.7&#8243; title_text_shadow_horizontal_length=&#8221;0em&#8221; title_text_shadow_vertical_length=&#8221;0em&#8221; title_text_shadow_blur_strength=&#8221;0em&#8221; body_text_shadow_horizontal_length=&#8221;0em&#8221; body_text_shadow_vertical_length=&#8221;0em&#8221; body_text_shadow_blur_strength=&#8221;0em&#8221;]<\/p>\n<p>Here is a C# implementation of the grasshopper component which contains an asynchronous program.\u00a0 You have two flags defining the state of the program. Once you run the program you set the\u00a0<span class=\"identifier\">taskIsRunning to true and once all tasks are completed you set it back to false. The\u00a0<\/span><span class=\"identifier\">taskIsCompleted flag is set to true in the same event however it is reset when the solution of the component is updated. In SolveInstance() method when no task is running and no tasks is completed (meaning component is updated when no task is running) we create an instance of our asynchronous program and assign handler to its events. As you can see in the code below when all tasks are completed we expire the solution and updated the outputs.<\/span><\/p>\n<p>[\/et_pb_accordion_item][et_pb_accordion_item title=&#8221;CODE&#8221; open=&#8221;off&#8221; _builder_version=&#8221;3.22.7&#8243; title_text_shadow_horizontal_length=&#8221;0em&#8221; title_text_shadow_vertical_length=&#8221;0em&#8221; title_text_shadow_blur_strength=&#8221;0em&#8221; body_text_shadow_horizontal_length=&#8221;0em&#8221; body_text_shadow_vertical_length=&#8221;0em&#8221; body_text_shadow_blur_strength=&#8221;0em&#8221; background_color=&#8221;#eeeeee&#8221;]<\/p>\n<pre style=\"font-family: Consolas; font-size: 13px; color: black;\"><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">    \/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n    <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> this is an example of implementation of Asynchronous Programming within grasshopper component<\/span>\n    <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n    <span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"keyword\" style=\"color: blue;\">class<\/span> <span class=\"class name\" style=\"color: #2b91af;\">AsychGHComponent<\/span> <span class=\"punctuation\">:<\/span> <span class=\"identifier\">GHCustomComponent<\/span>\n    <span class=\"punctuation\">{<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> it is true when task is running and <\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> then it is set to false after completation of all tasks.<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"keyword\" style=\"color: blue;\">bool<\/span> <span class=\"field name\">taskIsRunning<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">false<\/span><span class=\"punctuation\">;<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> it is true just after completaion of all tasks and <\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> then it is set to false after updating the data <\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"keyword\" style=\"color: blue;\">bool<\/span> <span class=\"field name\">taskIsCompleted<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">false<\/span><span class=\"punctuation\">;<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> if you wish to allow user to cancel operation<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"identifier\">CancellationTokenSource<\/span> <span class=\"field name\">cts<\/span><span class=\"punctuation\">;<\/span>\n \n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> instance of the asynched-programm<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"identifier\">AsynchronousProgram<\/span> <span class=\"field name\">_myProgramm<\/span><span class=\"punctuation\">;<\/span>\n \n        <span class=\"preprocessor keyword\" style=\"color: gray;\">#region<\/span> <span class=\"preprocessor text\">constructor<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> this is an example of implementation of <\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"class name\" style=\"color: #2b91af;\">AsychGHComponent<\/span><span class=\"punctuation\">()<\/span>\n          <span class=\"punctuation\">:<\/span> <span class=\"keyword\" style=\"color: blue;\">base<\/span><span class=\"punctuation\">(<\/span><span class=\"string\" style=\"color: #a31515;\">\"AsychGHComponent\"<\/span><span class=\"punctuation\">,<\/span> <span class=\"string\" style=\"color: #a31515;\">\"AP\"<\/span><span class=\"punctuation\">,<br \/><\/span><span class=\"string\" style=\"color: #a31515;\">              \"An example of Grasshopper plugin &amp; Event based asynchronous programming in C#\"<\/span><span class=\"punctuation\">,<\/span>              \n              <span class=\"string\" style=\"color: #a31515;\">\"mainCat\"<\/span><span class=\"punctuation\">,<\/span> <span class=\"string\" style=\"color: #a31515;\">\"subCat\"<\/span><span class=\"punctuation\">)<\/span>\n        <span class=\"punctuation\">{<\/span>\n        <span class=\"punctuation\">}<\/span>\n        <span class=\"preprocessor keyword\" style=\"color: gray;\">#endregion<\/span>\n \n        <span class=\"preprocessor keyword\" style=\"color: gray;\">#region<\/span> <span class=\"preprocessor text\">implementation of the base class<\/span>\n \n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> Registers all the input parameters for this component.<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"keyword\" style=\"color: blue;\">protected<\/span> <span class=\"keyword\" style=\"color: blue;\">override<\/span> <span class=\"keyword\" style=\"color: blue;\">void<\/span> <span class=\"method name\" style=\"color: #74531f;\">RegisterInputParams<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - unnecessary code - (TRANSIENT)\">GH_Component<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">GH_InputParamManager<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">pManager<\/span><span class=\"punctuation\">)<\/span>\n        <span class=\"punctuation\">{<\/span>\n            <span class=\"comment\" style=\"color: green;\">\/\/----------------------------------------------<\/span>\n            <span class=\"comment\" style=\"color: green;\">\/\/------------- your code ----------------------<\/span>\n            <span class=\"comment\" style=\"color: green;\">\/\/---------------------------------------------- <\/span>\n \n        <span class=\"punctuation\">}<\/span>\n \n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> Registers all the output parameters for this component.<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"keyword\" style=\"color: blue;\">protected<\/span> <span class=\"keyword\" style=\"color: blue;\">override<\/span> <span class=\"keyword\" style=\"color: blue;\">void<\/span> <span class=\"method name\" style=\"color: #74531f;\">RegisterOutputParams<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier - unnecessary code - (TRANSIENT)\">GH_Component<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">GH_OutputParamManager<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">pManager<\/span><span class=\"punctuation\">)<\/span>\n        <span class=\"punctuation\">{<\/span>\n            <span class=\"comment\" style=\"color: green;\">\/\/----------------------------------------------<\/span>\n            <span class=\"comment\" style=\"color: green;\">\/\/------------- your code ----------------------<\/span>\n            <span class=\"comment\" style=\"color: green;\">\/\/----------------------------------------------<\/span>\n        <span class=\"punctuation\">}<\/span>\n \n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> This is the method that actually does the work.<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">DA<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">The DA object can be used to retrieve data from input parameters and <\/span>\n        <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> to store data in output parameters.<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n        <span class=\"keyword\" style=\"color: blue;\">protected<\/span> <span class=\"keyword\" style=\"color: blue;\">override<\/span> <span class=\"keyword\" style=\"color: blue;\">void<\/span> <span class=\"method name\" style=\"color: #74531f;\">SolveInstance<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">IGH_DataAccess<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">DA<\/span><span class=\"punctuation\">)<\/span>\n        <span class=\"punctuation\">{<\/span>\n \n            <span class=\"comment\" style=\"color: green;\">\/\/ check if the task is running then ignore the update<\/span>\n            <span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier\">taskIsRunning<\/span><span class=\"punctuation\">)<\/span>\n                <span class=\"keyword - control\" style=\"color: #8f08c4;\">return<\/span><span class=\"punctuation\">;<\/span>\n \n            <span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier\">taskIsCompleted<\/span><span class=\"punctuation\">)<\/span>\n            <span class=\"punctuation\">{<\/span>\n \n                <span class=\"comment\" style=\"color: green;\">\/\/task is just completed we can update the solution !<\/span>\n \n                <span class=\"comment\" style=\"color: green;\">\/\/------------------------<\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/set the output data here<\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/------------------------<\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/ for the next call make sure we set the flag off again<\/span>\n                <span class=\"identifier\">taskIsCompleted<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">false<\/span><span class=\"punctuation\">;<\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/ dispose the cancellationtoken<\/span>\n                <span class=\"identifier\">cts<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">Dispose<\/span><span class=\"punctuation\">();<\/span>\n            <span class=\"punctuation\">}<\/span>\n            <span class=\"keyword - control\" style=\"color: #8f08c4;\">else<\/span>\n            <span class=\"punctuation\">{<\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/ the taskIsCompleted flag is not true therefore we can start new task !<\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/-------------------------------- cancellation -------------------------<\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/ you may allow user to cancel the operation by any means <\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/ simply call cts.Cancel();<\/span>\n                <span class=\"identifier\">cts<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">new<\/span> <span class=\"identifier\">CancellationTokenSource<\/span><span class=\"punctuation\">();<\/span> \n                <span class=\"comment\" style=\"color: green;\">\/\/----------------------------------------------------------------------<\/span>\n \n                <span class=\"comment\" style=\"color: green;\">\/\/-------------------------------- run asynched programm----------------<\/span>\n                <span class=\"identifier\">_myProgramm<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">new<\/span> <span class=\"identifier\">AsynchronousProgram<\/span><span class=\"punctuation\">();<\/span>\n                <span class=\"identifier\">_myProgramm<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">AllTasksAreComplete<\/span> <span class=\"operator\">+=<\/span> <span class=\"identifier\">_myProgramm_AllTasksAreComplete<\/span><span class=\"punctuation\">;<\/span>\n                <span class=\"identifier\">_myProgramm<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">OneTaskComplete<\/span> <span class=\"operator\">+=<\/span> <span class=\"identifier\">_myProgramm_OneTaskComplete<\/span><span class=\"punctuation\">;<\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/ set the flag so we don't call RunAsynchProgram twice<\/span>\n                <span class=\"identifier\">taskIsRunning<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">true<\/span><span class=\"punctuation\">;<\/span>\n                <span class=\"identifier\">_myProgramm<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">RunAsynchProgram<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">cts<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">Token<\/span><span class=\"punctuation\">);<\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/----------------------------------------------------------------------<\/span>\n            <span class=\"punctuation\">}<\/span>\n        <span class=\"punctuation\">}<\/span>\n \n        <span class=\"keyword\" style=\"color: blue;\">private<\/span> <span class=\"keyword\" style=\"color: blue;\">void<\/span> <span class=\"method name\" style=\"color: #74531f;\">_myProgramm_OneTaskComplete<\/span><span class=\"punctuation\">(<\/span><span class=\"keyword\" style=\"color: blue;\">object<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">sender<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">AsyncTaskCompleteArgs<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">e<\/span><span class=\"punctuation\">)<\/span>\n        <span class=\"punctuation\">{<\/span>\n            <span class=\"comment\" style=\"color: green;\">\/\/ one taks was completed.<\/span>\n            <span class=\"comment\" style=\"color: green;\">\/\/ you can report the progress \/ update preview \/ etc....<\/span>\n            <span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier\">e<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">Error<\/span><span class=\"operator\">==<\/span><span class=\"keyword\" style=\"color: blue;\">null<\/span><span class=\"punctuation\">)<\/span>\n            <span class=\"punctuation\">{<\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/report progress or update UI<\/span>\n            <span class=\"punctuation\">}<\/span>\n            <span class=\"keyword - control\" style=\"color: #8f08c4;\">else<\/span>\n            <span class=\"punctuation\">{<\/span>\n                <span class=\"comment\" style=\"color: green;\">\/\/ check for user cancellation or maange excpetions...<\/span>\n            <span class=\"punctuation\">}<\/span>\n \n        <span class=\"punctuation\">}<\/span>\n \n        <span class=\"keyword\" style=\"color: blue;\">private<\/span> <span class=\"keyword\" style=\"color: blue;\">void<\/span> <span class=\"method name\" style=\"color: #74531f;\">_myProgramm_AllTasksAreComplete<\/span><span class=\"punctuation\">(<\/span><span class=\"keyword\" style=\"color: blue;\">object<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">sender<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">EventArgs<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">e<\/span><span class=\"punctuation\">)<\/span>\n        <span class=\"punctuation\">{<\/span>\n            <span class=\"comment\" style=\"color: green;\">\/\/ all tasks are completed we set the flag and expire the solution<\/span>\n            <span class=\"identifier\">taskIsCompleted<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">true<\/span><span class=\"punctuation\">;<\/span>\n            <span class=\"identifier\">taskIsRunning<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">false<\/span><span class=\"punctuation\">;<\/span>\n            <span class=\"comment\" style=\"color: green;\">\/\/ expire the solution, this jupms back to SolveInstance() <\/span>\n            <span class=\"identifier\">ExpireSolution<\/span><span class=\"punctuation\">(<\/span><span class=\"keyword\" style=\"color: blue;\">true<\/span><span class=\"punctuation\">);<\/span>\n        <span class=\"punctuation\">}<\/span>\n        <span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"keyword\" style=\"color: blue;\">override<\/span> <span class=\"identifier\">Guid<\/span> <span class=\"property name\">ComponentGuid<\/span>\n        <span class=\"punctuation\">{<\/span>\n            <span class=\"keyword\" style=\"color: blue;\">get<\/span> <span class=\"punctuation\">{<\/span> <span class=\"keyword - control\" style=\"color: #8f08c4;\">return<\/span> <span class=\"keyword\" style=\"color: blue;\">new<\/span> <span class=\"identifier\">Guid<\/span><span class=\"punctuation\">(<\/span><span class=\"string\" style=\"color: #a31515;\">\"e2d943bd-d860-4f71-b0bd-a366d2200451\"<\/span><span class=\"punctuation\">);<\/span> <span class=\"punctuation\">}<\/span>\n        <span class=\"punctuation\">}<\/span>\n        <span class=\"preprocessor keyword\" style=\"color: gray;\">#endregion<\/span>\n \n    <span class=\"punctuation\">}<\/span><\/pre>\n<p>[\/et_pb_accordion_item][et_pb_accordion_item title=&#8221;Asynchronous Program&#8221; open=&#8221;off&#8221; _builder_version=&#8221;3.22.7&#8243; title_text_shadow_horizontal_length=&#8221;0em&#8221; title_text_shadow_vertical_length=&#8221;0em&#8221; title_text_shadow_blur_strength=&#8221;0em&#8221; body_text_shadow_horizontal_length=&#8221;0em&#8221; body_text_shadow_vertical_length=&#8221;0em&#8221; body_text_shadow_blur_strength=&#8221;0em&#8221;]<\/p>\n<p>In this class we use <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.componentmodel.asyncoperationmanager?view=net-5.0\"><em><strong>AsyncOperationManager<\/strong> <\/em><\/a>to wrap our operation into an <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.componentmodel.asyncoperation?view=net-5.0\"><em><strong>AsyncOperation<\/strong> <\/em><\/a>and then assign a call back to it. The call back will fire an event when the operation is completed or encountered an error. Using\u00a0 <a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.componentmodel.asynccompletedeventargs?view=net-5.0\"><em><strong>AsyncTaskCompleteArgs<\/strong> <\/em><\/a>class we wrap our data which we have got from the operation into an event argument and then raise an event which is then catch from grasshopper plugin. Note that event is raised after completion of each task, therefore you must find a way to know when all tasks are completed , in this example I assume we know the total number of tasks and hence when we count the number of call backs and if it reaches the total number of task we raise our\u00a0\u00a0<strong>AllTasksAreComplete <\/strong>event which expires the grasshopper solution. You can also report the progress or update the grasshopper UI while listening to the\u00a0<strong>OneTaskComplete<\/strong> event from GH component<\/p>\n<p>[\/et_pb_accordion_item][et_pb_accordion_item title=&#8221;CODE&#8221; open=&#8221;off&#8221; _builder_version=&#8221;3.22.7&#8243; title_text_shadow_horizontal_length=&#8221;0em&#8221; title_text_shadow_vertical_length=&#8221;0em&#8221; title_text_shadow_blur_strength=&#8221;0em&#8221; body_text_shadow_horizontal_length=&#8221;0em&#8221; body_text_shadow_vertical_length=&#8221;0em&#8221; body_text_shadow_blur_strength=&#8221;0em&#8221; background_color=&#8221;#eeeeee&#8221;]<\/p>\n<pre style=\"font-family: Consolas; font-size: 13px; color: black;\"><span class=\"xml doc comment - delimiter\" style=\"color: gray;\"> \/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> this is an example of Async programming in DotNet<\/span>\n <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n <span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"keyword\" style=\"color: blue;\">class<\/span> <span class=\"class name\" style=\"color: #2b91af;\">AsynchronousProgram<\/span>\n <span class=\"punctuation\">{<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> call back to raise the <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">RowComplete<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> event<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">private<\/span> <span class=\"identifier\">SendOrPostCallback<\/span> <span class=\"field name\">taskCompletedCallBack<\/span><span class=\"punctuation\">;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> somehow record the number of tasks you need to run. if that's not possible<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> then you may need to find a way to know if all tasks are completed.<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">int<\/span> <span class=\"field name\">numberOFTasks<\/span> <span class=\"punctuation\">;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> number of tasks which are completed.<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">int<\/span> <span class=\"field name\">completedTasks<\/span> <span class=\"operator\">=<\/span> <span class=\"number\">0<\/span><span class=\"punctuation\">;<\/span>\n \n     <span class=\"preprocessor keyword\" style=\"color: gray;\">#region<\/span> <span class=\"preprocessor text\">constructor<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> construct the graph , note you must call <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> ComputeGraphAsynch()<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> to calculate the Data<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"class name\" style=\"color: #2b91af;\">AsynchronousProgram<\/span><span class=\"punctuation\">()<\/span>\n     <span class=\"punctuation\">{<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/-------------------------------------<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/---------------your code-------------<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/-------------------------------------<\/span>\n \n         <span class=\"comment\" style=\"color: green;\">\/\/ create an instance of the callback, this callback fires the event for task completion<\/span>\n         <span class=\"identifier\">taskCompletedCallBack<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">new<\/span> <span class=\"identifier\">SendOrPostCallback<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">TaskCompleted<\/span><span class=\"punctuation\">);<\/span>\n     <span class=\"punctuation\">}<\/span>\n \n     <span class=\"preprocessor keyword\" style=\"color: gray;\">#endregion<\/span>\n \n \n     <span class=\"preprocessor keyword\" style=\"color: gray;\">#region<\/span> <span class=\"preprocessor text\">Events and Delegates<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> raises when computation of a taks is completed<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"keyword\" style=\"color: blue;\">event<\/span> <span class=\"identifier\">EventHandler<\/span><span class=\"punctuation\">&lt;<\/span><span class=\"identifier\">AsyncTaskCompleteArgs<\/span><span class=\"punctuation\">&gt;<\/span> <span class=\"event name\">OneTaskComplete<\/span><span class=\"punctuation\">;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> raises when computation of all tasks are completed<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"keyword\" style=\"color: blue;\">event<\/span> <span class=\"identifier\">EventHandler<\/span><span class=\"punctuation\">&lt;<\/span><span class=\"identifier\">EventArgs<\/span><span class=\"punctuation\">&gt;<\/span> <span class=\"event name\">AllTasksAreComplete<\/span><span class=\"punctuation\">;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> a delegate which holds necessar data to compute a task<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">asyncOperation<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">state<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">cts<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">private<\/span> <span class=\"keyword\" style=\"color: blue;\">delegate<\/span> <span class=\"keyword\" style=\"color: blue;\">void<\/span> <span class=\"delegate name\" style=\"color: #2b91af;\">TaskCallBack<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">AsyncOperation<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">asyncOperation<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">int<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">state<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">CancellationToken<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">cts<\/span><span class=\"punctuation\">);<\/span>\n     <span class=\"preprocessor keyword\" style=\"color: gray;\">#endregion<\/span>\n \n     <span class=\"preprocessor keyword\" style=\"color: gray;\">#region<\/span> <span class=\"preprocessor text\">implementatio of asycnh operations<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> the main method you need to call from UI thread (grasshopper plug-in)<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> listen to the methods <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">OneTaskComplete<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> and <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">AllTasksAreComplete<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> for completion<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">kuka<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">singularityCheck<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">cts<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"keyword\" style=\"color: blue;\">void<\/span> <span class=\"method name\" style=\"color: #74531f;\">RunAsynchProgram<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">CancellationToken<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">cts<\/span><span class=\"punctuation\">)<\/span>\n     <span class=\"punctuation\">{<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/you may create multiple operation using a loop or recursion or ant other ways of iteration<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/just make sure each operation has a unique id (state) <br \/>         \/\/here I am just usig the iterator for simplicity             <\/span>\n\n         <span class=\"keyword - control\" style=\"color: #8f08c4;\">for<\/span><span class=\"punctuation\">(<\/span><span class=\"keyword\" style=\"color: blue;\">int<\/span> <span class=\"local name\" style=\"color: #1f377f;\">i<\/span><span class=\"operator\">=<\/span><span class=\"number\">0<\/span><span class=\"punctuation\">;<\/span><span class=\"identifier\">i<\/span><span class=\"operator\">&lt;<\/span> <span class=\"identifier\">numberOFTasks<\/span><span class=\"punctuation\">;<\/span><span class=\"identifier\">i<\/span><span class=\"operator\">++<\/span><span class=\"punctuation\">)<\/span>\n         <span class=\"punctuation\">{<\/span> \n             <span class=\"comment\" style=\"color: green;\">\/\/ create an asynch operation <\/span>\n             <span class=\"identifier\">AsyncOperation<\/span> <span class=\"local name\" style=\"color: #1f377f;\">asyncOperation<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier\">AsyncOperationManager<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">CreateOperation<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">i<\/span><span class=\"punctuation\">);<\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/ build a call back <\/span>\n             <span class=\"identifier\">TaskCallBack<\/span> <span class=\"local name\" style=\"color: #1f377f;\">myCallBack<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">new<\/span> <span class=\"identifier\">TaskCallBack<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">computeTaskAsynch<\/span><span class=\"punctuation\">);<\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/ enque the task using invoke. The call back will call the operation on the first possible <\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/thread and await its completion. when the tast is completed the OnTaskComplete() method<\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/gets called and an event is fired <\/span>\n             <span class=\"identifier\">myCallBack<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">BeginInvoke<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">asyncOperation<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">i<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">cts<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">null<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">null<\/span><span class=\"punctuation\">);<\/span>\n \n         <span class=\"punctuation\">}<\/span>\n \n     <span class=\"punctuation\">}<\/span>\n \n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> this method is used for call back only !<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> compute a single task (given state is the index of the row to be computed)<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">        <\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">asyncOperation<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">state<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">the index of the row in the graph (used also as Id for the action)<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">token<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">The cancellation token from the UI thread<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">void<\/span> <span class=\"method name\" style=\"color: #74531f;\">computeTaskAsynch<\/span><span class=\"punctuation\">(<\/span> <span class=\"identifier\">AsyncOperation<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">asyncOperation<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">int<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">state<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">CancellationToken<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">token<\/span><span class=\"punctuation\">)<\/span>\n     <span class=\"punctuation\">{<\/span>\n \n         <span class=\"identifier\">AsyncTaskCompleteArgs<\/span> <span class=\"local name\" style=\"color: #1f377f;\">e<\/span><span class=\"punctuation\">;<\/span>\n \n         <span class=\"keyword - control\" style=\"color: #8f08c4;\">try<\/span>\n         <span class=\"punctuation\">{<\/span>                \n             <span class=\"comment\" style=\"color: green;\">\/\/ do your stuff <\/span>\n             <span class=\"keyword\" style=\"color: blue;\">var<\/span> <span class=\"local name\" style=\"color: #1f377f;\">data<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier\">DoSomething<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">state<\/span><span class=\"punctuation\">,<\/span><span class=\"identifier\">token<\/span><span class=\"punctuation\">);<\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/ build the event argument <\/span>\n             <span class=\"identifier\">e<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">new<\/span> <span class=\"identifier\">AsyncTaskCompleteArgs<\/span><span class=\"punctuation\">(<\/span><span class=\"keyword\" style=\"color: blue;\">null<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">false<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">state<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">data<\/span><span class=\"punctuation\">);<\/span>\n         <span class=\"punctuation\">}<\/span>\n         <span class=\"keyword - control\" style=\"color: #8f08c4;\">catch<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier\">Exception<\/span> <span class=\"local name\" style=\"color: #1f377f;\">exception<\/span><span class=\"punctuation\">)<\/span>\n         <span class=\"punctuation\">{<\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/ user may cancel the operation or an exception may be thrown <\/span>\n             <span class=\"identifier\">e<\/span> <span class=\"operator\">=<\/span> <span class=\"keyword\" style=\"color: blue;\">new<\/span> <span class=\"identifier\">AsyncTaskCompleteArgs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">exception<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">false<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">state<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">null<\/span><span class=\"punctuation\">);<\/span>\n \n         <span class=\"punctuation\">}<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/ post the operation and wait for the completion event(s)<\/span>\n         <span class=\"identifier\">asyncOperation<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">PostOperationCompleted<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">taskCompletedCallBack<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">e<\/span><span class=\"punctuation\">);<\/span>\n     <span class=\"punctuation\">}<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> do the actual work<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">taksId<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">private<\/span> <span class=\"keyword\" style=\"color: blue;\">object<\/span> <span class=\"method name\" style=\"color: #74531f;\">DoSomething<\/span><span class=\"punctuation\">(<\/span><span class=\"keyword\" style=\"color: blue;\">int<\/span> <span class=\"parameter name - unnecessary code - (TRANSIENT)\" style=\"color: #1f377f;\">taksId<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">CancellationToken<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">token<\/span><span class=\"punctuation\">)<\/span>\n     <span class=\"punctuation\">{<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/ check for uer interruption <\/span>\n         <span class=\"identifier\">token<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">ThrowIfCancellationRequested<\/span><span class=\"punctuation\">();<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/----------------------<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/------your code-------<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/----------------------<\/span>\n         \n         <span class=\"keyword - control\" style=\"color: #8f08c4;\">return<\/span> <span class=\"keyword\" style=\"color: blue;\">null<\/span><span class=\"punctuation\">;<\/span> <span class=\"comment\" style=\"color: green;\">\/\/ you can return something and pass it via event argument<\/span>\n     <span class=\"punctuation\">}<\/span>\n \n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> raise the RowComplete event, and if all rows are completed then raises the GraphComplete event<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">e<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">void<\/span> <span class=\"method name\" style=\"color: #74531f;\">OnTaskComplete<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">AsyncTaskCompleteArgs<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">e<\/span><span class=\"punctuation\">)<\/span>\n     <span class=\"punctuation\">{<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/ inrement the number of tasks which are completed .<\/span>\n         <span class=\"identifier\">completedTasks<\/span><span class=\"operator\">++<\/span><span class=\"punctuation\">;<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/ in case of the error see if the user has canclled <\/span>\n         <span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier\">e<\/span><span class=\"operator\">.<\/span><span class=\"identifier\">Error<\/span> <span class=\"operator\">!=<\/span> <span class=\"keyword\" style=\"color: blue;\">null<\/span><span class=\"punctuation\">)<\/span>\n         <span class=\"punctuation\">{<\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/----------------------<\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/------your code-------<\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/----------------------<\/span>\n         <span class=\"punctuation\">}<\/span>\n         <span class=\"keyword - control\" style=\"color: #8f08c4;\">else<\/span>\n         <span class=\"punctuation\">{<\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/----------------------<\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/------your code-------<\/span>\n             <span class=\"comment\" style=\"color: green;\">\/\/----------------------<\/span>\n             \n         <span class=\"punctuation\">}<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/ raise the event for a single task completion<\/span>\n         <span class=\"identifier\">OneTaskComplete<\/span><span class=\"operator\">?.<\/span><span class=\"identifier\">Invoke<\/span><span class=\"punctuation\">(<\/span><span class=\"keyword\" style=\"color: blue;\">this<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">e<\/span><span class=\"punctuation\">);<\/span>\n         <span class=\"comment\" style=\"color: green;\">\/\/ if all tasks are completed then raise the AllTasksAreComplete event<\/span>\n         <span class=\"keyword - control\" style=\"color: #8f08c4;\">if<\/span> <span class=\"punctuation\">(<\/span><span class=\"identifier\">completedTasks<\/span> <span class=\"operator\">==<\/span> <span class=\"identifier\">numberOFTasks<\/span><span class=\"punctuation\">)<\/span>\n             <span class=\"identifier\">AllTasksAreComplete<\/span><span class=\"operator\">?.<\/span><span class=\"identifier\">Invoke<\/span><span class=\"punctuation\">(<\/span><span class=\"keyword\" style=\"color: blue;\">this<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">new<\/span> <span class=\"identifier\">EventArgs<\/span><span class=\"punctuation\">());<\/span>\n     <span class=\"punctuation\">}<\/span>\n \n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> calls the function <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">OnRowComplete()<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> from the call back<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - attribute name\" style=\"color: gray;\"> name<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">=<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"identifier\">state<\/span><span class=\"xml doc comment - attribute quotes\" style=\"color: gray;\">\"<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">param<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n     <span class=\"keyword\" style=\"color: blue;\">void<\/span> <span class=\"method name\" style=\"color: #74531f;\">TaskCompleted<\/span><span class=\"punctuation\">(<\/span><span class=\"keyword\" style=\"color: blue;\">object<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">state<\/span><span class=\"punctuation\">)<\/span>\n     <span class=\"punctuation\">{<\/span>\n         <span class=\"identifier\">OnTaskComplete<\/span><span class=\"punctuation\">((<\/span><span class=\"identifier\">AsyncTaskCompleteArgs<\/span><span class=\"punctuation\">)<\/span><span class=\"identifier\">state<\/span><span class=\"punctuation\">);<\/span>\n     <span class=\"punctuation\">}<\/span>\n     <span class=\"preprocessor keyword\" style=\"color: gray;\">#endregion<\/span>\n \n <span class=\"punctuation\">}<\/span>\n<\/pre>\n<p>[\/et_pb_accordion_item][et_pb_accordion_item title=&#8221;Async Event&#8221; open=&#8221;off&#8221; _builder_version=&#8221;3.22.7&#8243; title_text_shadow_horizontal_length=&#8221;0em&#8221; title_text_shadow_vertical_length=&#8221;0em&#8221; title_text_shadow_blur_strength=&#8221;0em&#8221; body_text_shadow_horizontal_length=&#8221;0em&#8221; body_text_shadow_vertical_length=&#8221;0em&#8221; body_text_shadow_blur_strength=&#8221;0em&#8221;]<\/p>\n<p>Lastly you need to implement the\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/api\/system.componentmodel.asynccompletedeventargs?view=net-5.0\"><em><strong>AsyncCompletedEventArgs<\/strong> <\/em><\/a>class whihc is used to transfer data by an async event. Simply pack your data and (instead of the object argument in template code) and you can read it from Grasshopper component. It is always uesfull to send data about the particular task which is completed as well as the number of completed tasks in case you want to display some progress.<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_accordion_item][et_pb_accordion_item title=&#8221;CODE&#8221; open=&#8221;on&#8221; _builder_version=&#8221;3.22.7&#8243; title_text_shadow_horizontal_length=&#8221;0em&#8221; title_text_shadow_vertical_length=&#8221;0em&#8221; title_text_shadow_blur_strength=&#8221;0em&#8221; body_text_shadow_horizontal_length=&#8221;0em&#8221; body_text_shadow_vertical_length=&#8221;0em&#8221; body_text_shadow_blur_strength=&#8221;0em&#8221; background_color=&#8221;#eeeeee&#8221;]<\/p>\n<pre style=\"font-family: Consolas; font-size: 13px; color: black;\"><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n    <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> implement <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\">AsyncCompletedEventArgs<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">c<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> class <\/span>\n    <span class=\"xml doc comment - delimiter\" style=\"color: gray;\">\/\/\/<\/span><span class=\"xml doc comment - text\" style=\"color: green;\"> <\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&lt;\/<\/span><span class=\"xml doc comment - name\" style=\"color: gray;\">summary<\/span><span class=\"xml doc comment - delimiter\" style=\"color: gray;\">&gt;<\/span>\n    <span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"keyword\" style=\"color: blue;\">class<\/span> <span class=\"class name\" style=\"color: #2b91af;\">AsyncTaskCompleteArgs<\/span> <span class=\"punctuation\">:<\/span> <span class=\"identifier\">AsyncCompletedEventArgs<\/span>\n    <span class=\"punctuation\">{<\/span>\n        <span class=\"comment\" style=\"color: green;\">\/\/----------------------------------------------<\/span>\n        <span class=\"comment\" style=\"color: green;\">\/\/------------- your internal data--------------<\/span>\n        <span class=\"comment\" style=\"color: green;\">\/\/----------------------------------------------<\/span>\n        <span class=\"comment\" style=\"color: green;\">\/\/ data to be transgered by event argument<\/span>\n        <span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"keyword\" style=\"color: blue;\">object<\/span> <span class=\"property name\">Data<\/span> <span class=\"punctuation\">{<\/span> <span class=\"keyword\" style=\"color: blue;\">get<\/span><span class=\"punctuation\">;<\/span> <span class=\"keyword\" style=\"color: blue;\">private<\/span> <span class=\"keyword\" style=\"color: blue;\">set<\/span><span class=\"punctuation\">;<\/span> <span class=\"punctuation\">}<\/span>\n        <span class=\"keyword\" style=\"color: blue;\">public<\/span> <span class=\"class name\" style=\"color: #2b91af;\">AsyncTaskCompleteArgs<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">Exception<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">exception<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">bool<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">cancelled<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">int<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">userState<\/span><span class=\"punctuation\">,<\/span> <span class=\"keyword\" style=\"color: blue;\">object<\/span> <span class=\"parameter name\" style=\"color: #1f377f;\">mydata<\/span><span class=\"punctuation\">)<\/span> <br \/><span class=\"punctuation\">       :<\/span> <span class=\"keyword\" style=\"color: blue;\">base<\/span><span class=\"punctuation\">(<\/span><span class=\"identifier\">exception<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">cancelled<\/span><span class=\"punctuation\">,<\/span> <span class=\"identifier\">userState<\/span><span class=\"punctuation\">)<\/span>\n        <span class=\"punctuation\">{<\/span>\n            <span class=\"identifier\">Data<\/span> <span class=\"operator\">=<\/span> <span class=\"identifier\">mydata<\/span><span class=\"punctuation\">;<\/span>\n        <span class=\"punctuation\">}<\/span>\n    <span class=\"punctuation\">}<\/span><\/pre>\n<p>[\/et_pb_accordion_item][\/et_pb_accordion][et_pb_code _builder_version=&#8221;3.22.7&#8243;][\/et_pb_code][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":""},"categories":[64],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Grasshopper plugin &amp; Event based asynchronous programming in C# - Parametric Zoo<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Grasshopper plugin &amp; Event based asynchronous programming in C# - Parametric Zoo\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"Parametric Zoo\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-28T20:35:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-28T21:36:03+00:00\" \/>\n<meta name=\"author\" content=\"PARA\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"PARA\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.parametriczoo.com\/#website\",\"url\":\"https:\/\/www.parametriczoo.com\/\",\"name\":\"Parametric Zoo\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.parametriczoo.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/\",\"url\":\"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/\",\"name\":\"Grasshopper plugin & Event based asynchronous programming in C# - Parametric Zoo\",\"isPartOf\":{\"@id\":\"https:\/\/www.parametriczoo.com\/#website\"},\"datePublished\":\"2021-07-28T20:35:18+00:00\",\"dateModified\":\"2021-07-28T21:36:03+00:00\",\"author\":{\"@id\":\"https:\/\/www.parametriczoo.com\/#\/schema\/person\/0368c6eb8bfe3a003504793be2a2e0e3\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.parametriczoo.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Grasshopper plugin &#038; Event based asynchronous programming in C#\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.parametriczoo.com\/#\/schema\/person\/0368c6eb8bfe3a003504793be2a2e0e3\",\"name\":\"PARA\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.parametriczoo.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2b2ff0ff40493545df12d0b31a504675?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2b2ff0ff40493545df12d0b31a504675?s=96&d=mm&r=g\",\"caption\":\"PARA\"},\"url\":\"https:\/\/www.parametriczoo.com\/index.php\/author\/para\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Grasshopper plugin & Event based asynchronous programming in C# - Parametric Zoo","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/","og_locale":"en_US","og_type":"article","og_title":"Grasshopper plugin & Event based asynchronous programming in C# - Parametric Zoo","og_url":"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/","og_site_name":"Parametric Zoo","article_published_time":"2021-07-28T20:35:18+00:00","article_modified_time":"2021-07-28T21:36:03+00:00","author":"PARA","twitter_card":"summary_large_image","twitter_misc":{"Written by":"PARA"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.parametriczoo.com\/#website","url":"https:\/\/www.parametriczoo.com\/","name":"Parametric Zoo","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.parametriczoo.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/","url":"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/","name":"Grasshopper plugin & Event based asynchronous programming in C# - Parametric Zoo","isPartOf":{"@id":"https:\/\/www.parametriczoo.com\/#website"},"datePublished":"2021-07-28T20:35:18+00:00","dateModified":"2021-07-28T21:36:03+00:00","author":{"@id":"https:\/\/www.parametriczoo.com\/#\/schema\/person\/0368c6eb8bfe3a003504793be2a2e0e3"},"breadcrumb":{"@id":"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.parametriczoo.com\/index.php\/2021\/07\/28\/grasshopper-plugin-event-based-asynchronous-programming-in-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.parametriczoo.com\/"},{"@type":"ListItem","position":2,"name":"Grasshopper plugin &#038; Event based asynchronous programming in C#"}]},{"@type":"Person","@id":"https:\/\/www.parametriczoo.com\/#\/schema\/person\/0368c6eb8bfe3a003504793be2a2e0e3","name":"PARA","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.parametriczoo.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2b2ff0ff40493545df12d0b31a504675?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2b2ff0ff40493545df12d0b31a504675?s=96&d=mm&r=g","caption":"PARA"},"url":"https:\/\/www.parametriczoo.com\/index.php\/author\/para\/"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/posts\/1096"}],"collection":[{"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/comments?post=1096"}],"version-history":[{"count":0,"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/posts\/1096\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/media?parent=1096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/categories?post=1096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.parametriczoo.com\/index.php\/wp-json\/wp\/v2\/tags?post=1096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}