Example #1
0
        /// <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);
            }
        }
Example #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());
        }
Example #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);
    }
Example #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);
 }
Example #6
0
 public SomeClass(SomeType state, SomeEventHandler eventHandler)
 {
     _state            = state;
     someEventHandler += MyDelegate;
 }