Demo entry 6644738

dsa

   

Submitted by anonymous on Oct 06, 2017 at 10:40
Language: C#. Code size: 841 Bytes.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            new DoAsyncStuff().Toplat(23, 23);
            Console.WriteLine("Finito");
            Thread.Sleep(200);       //Bunu kullanmazsan async metod bitmeden programdan ├ž─▒kabilir...
            Console.WriteLine("Program Exiting...");
        }
    }

    class DoAsyncStuff
    {
        public async void Toplat(int a1, int a2)
        {
            int result = await Task.Run(() => Topla(a1, a2));
            Console.WriteLine(result);
        }

        private int Topla(int i1, int i2)
        {
            return i1 + i2;

        }
    }
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).