1

If some methods are called that have no other calls within them but perhaps take a long time to complete, does the order of execution remain the same as called? For example...

public class Test
{
    static void Main()
    {
        Method1();
        Method2();        
    }
    static void Method1()
    {
        // Perhaps has many calculations that take a long time to complete
    }
    static void Method2()
    {            
    }

So would method 2 ever run before method 1 is finished? What could make 2 run before 1 has finished? Thanks

  • 4
    Method2 will only run after Method1 is finished because you have a single thread. You might want to read about threads. – Yacoub Massad Feb 17 '16 at 16:25
  • 2
    There's nothing in this code that would cause any sort of threading or asynchronous operation. Code executes in the order in which it's evaluated. – David Feb 17 '16 at 16:26
  • I'll dupe @YacoubMassad comment: `Method2` will only run **after** `Method1` is finished. Read about [threading](http://www.albahari.com/threading/). – Sinatr Feb 17 '16 at 16:38

0 Answers0