Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 952109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:50:22+00:00 2026-05-15T23:50:22+00:00

I’m attempting to work on a microthread message passing library in C# using mono.

  • 0

I’m attempting to work on a microthread message passing library in C# using mono. Since Mono 2.4 or so, apparently continuations (not yield) have been available under ‘Mono.Tasklets’. However, these lack any documentation that I can find, and while my general use of them works, I get an occasional (but reproducable) crash that the debugger won’t attach to.

My specific questions are:

Does anyone know what the Mark() function is, and where/when I need to call it? It seems to be a one-time initialization, but I don’t know why that wouldn’t be in the constructor then.

Are there limitations on using multiple continuations? I’ve discovered that you cannot pass a continuation to another thread, but it seems I can store multiple continuations and switch back and forth?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:50:23+00:00Added an answer on May 15, 2026 at 11:50 pm

    LE: Regarding the crash problem see these open bugs: Bug 566324 , Bug 580791 , Bug 602502

    I’m fairly new to this myself, I present here the information I gathered so far. Maybe it will be useful.

    1) The Mono.Tasklets library (described by Miguel de Icaza [READ: here]) is a continuation library that can be used to construct various forms of continuation systems and light weight(LW) threads.

    A simple way of picturing this is the Mono-version of C’s longjmp/setjmp, they can only be used to unwind the stack.

    The library was initially developed by a guy [READ: here] and now it’s included in Mono and documented [READ: here] (follow those links and you’ll find more information)

    That guy implemented a Microthreading library on top of this abstraction. and now that has been ported to Mono.Tasklets framework

    2) A continuation is an object that can be used to store the current execution state and it can then be used to restore the stored state later.

    “Execution state” here means the stack, which includes call stack and local variables, and the processor’s registers.

    When the stored state is restored the program execution looks like it jumps back to the position where the state was saved, with all the local variables restored.

    An example in C. and more info on Wikipedia/Continuations

    3) The API is :

    public class Continuation {
          public Continuation ();
          public void Mark ();
          public int Store (int state);
          public void Restore (int state);
     }
    

    Continuations can be used to implement microthreads. You can look at the code from Mono.MicroThreads available at Github [READ: here]

        public Continuation()
        {
            m_handle = alloc_continuation();
            Print("Continuation()");
        }
    
        public void Mark()
        {
            Print("Mark()");
            // skip 1 frame, ie. this function
            mark_continuation_frame(m_handle, 1);
        }
    
        public int Store(int data)
        {
            Print("Store({0})", data);
            int res = store_continuation(m_handle, data);
            Print("Store({0}) = {1}", data, res);
            return res;
        }
    
        public void Restore(int data)
        {
            Print("Restore({0})", data);
            restore_continuation(m_handle, data);
            Print("Restore() exit (NEVER REACHED)");
        }
    

    From what is presented here:

    Mark() it is used to mark the topmost frame to be stored

    Store(x) stores the current state to the continuation, and returns the given integer x.

    Restore(y) restores the stored state, and returns the given integer y.
    (Note that the integer y given to Restore is actually returned from the Store() method, because that’s where we are after the state has been restored.)

    static void Main()
    {
     Continuation c = new Continuation();
     c.Mark();
     int foo = 123;
     int val = c.Store(0);
     Console.WriteLine("{0} {1}", val, foo);
     foo = 321;
     if (val < 5)
         c.Restore(val + 1);
    }
    

    When you call Store() the current state of execution is recorded and it is possible to go back to this state by invoking Restore().

    The caller to Store() tells whether it is the initial store or a restore point based on the result from Store:

     var c = new Continuation ();
     ...
    
     switch (c.Store (0)){
     case 0:
          // First invocation
     case 1:
          // Restored from the point ahead.
     }
     ...
     // Jump back to the switch statement.
     c.Restore (1); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 485k
  • Answers 485k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This should work: $(this).nextAll().slice(0,4).attr(…) Update: This will work, too: $(this).nextAll("*:lt(4)").attr(…) May 16, 2026 at 7:41 am
  • Editorial Team
    Editorial Team added an answer First, get rid of getApplicationContext(). You almost never need it… May 16, 2026 at 7:41 am
  • Editorial Team
    Editorial Team added an answer delay() only works within an animation queue - so yes,… May 16, 2026 at 7:41 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.