/// <summary>
        /// Raises an event.
        /// </summary>
        /// <param name="s"></param>
        public void RaiseSomeEvent(String s)
        {
            // Save the field in a temporary variable, to avoid a possible race
            // condition.
            SomeEventHandler t = m_someEvent;

            // If at least one delegate is registered, invoke all the delegates.
            if (t != null)
            {
                t(this, s);
            }
        }
Exemple #2
0
        public void RunSomething()
        {
            SomeEventHandler += async(sender, args) =>
            {
                var trials = ++TrialCount;
                Console.WriteLine($"Started trial: {trials}");
                await DoSomethingSlow();

                Console.WriteLine($"Done with trial {trials}");
            };

            SomeEventHandler?.Invoke(this, new EventArgs());
        }
Exemple #3
0
    public static int Main()
    {
        Z z = new Z();

        int result = z.Test();

        if (result != 0)
        {
            return(result);
        }

        if (BuildStarted != null)
        {
            BuildStarted();
        }
        BuildStarted = new SomeEventHandler(a);
        if (BuildStarted() != 1)
        {
            return(50);
        }

        return(0);
    }
Exemple #4
0
	public static int Main ()
	{
		Z z = new Z ();

		int result = z.Test ();

		if (result != 0)
			return result;

         	if (BuildStarted != null) {
             		BuildStarted();
         	}
		BuildStarted = new SomeEventHandler (a);
		if (BuildStarted () != 1)
			return 50; 

		return 0;
	}
 public static CreateCommand(SomeType state, SomeEventHandler eventHandler)
 {
     eventHandler += (s, e) => MyDelegate(state, s, e);
 }
Exemple #6
0
 public SomeClass(SomeType state, SomeEventHandler eventHandler)
 {
     _state            = state;
     someEventHandler += MyDelegate;
 }