Menu

rtSignal home

Ogoun

The project allows to use signals in .NET applications.

To get to this concept, you need to take some of the rules:

  • strict division of classes of data and business logic
  • immutability of data after transmission signal
  • do not use threads in signal handlers
  • All methods of the business logic classes should be private, except for the constructor and destructor (or dispose)

Code sample

Starting, running search handlers, and the creation of slots.
The first way, the use of assembly:

rtSignalCore.AppendAssembly(Assembly.GetEntryAssembly());

,the second path, the use of class instances of business logic:

rtSignalCore.AppendTypeInstance(new BusinessLogicClass());

Signal:

public enum SomeNameSignals
{
    Signal1,
    Signal2
}

Business logic class:

[rtSignalParticipator]
class BusinessLogicClass
{
    // asynchronous signal processing
    [rtSignalAsyncHandler(SomeNameSignals.SignalWithoutArguments)]
    void Process_SignalWithoutArguments(string path)
    {
    ...
    }

    // asynchronous signal processing
    [rtSignalAsyncHandler(SomeNameSignals.SignalWithOneArg)]
    void Process_SignalWithOneArg(string data)
    {
    ...
    }

    [rtSignalHandler(SignalIdentifierEnum.SignalWithTwoArgs)]
    void Process_SignalWithTwoArgs(string filePath, FileInfo file)
    {
    ...
    }
}

Signal generation:

rtSignalCore.Signal(SomeNameSignals.SignalWithoutArguments);

or

rtSignalCore.Signal(SomeNameSignals.SignalWithOneArg, "Hello, world!");

or

rtSignalCore.Signal(SomeNameSignals.SignalWithTwoArgs, filePath, new FileInfo(filePath));

The handler of signal of finished processing the said signal. Including the completion of his asynchronous handlers:

[rtSignalCompletedAsyncHandler(SomeNameSignals.SignalWithoutArguments)]
void CompleteProcessings_SignalWithoutArguments()
{
    // ToDo
}

or

[rtSignalCompletedAsyncHandler(SomeNameSignals.SignalWithOneArg)]
void CompleteProcessings_SignalWithOneArg(string data)
{
    // ToDo
}

To mark the signal handlers available the following attributes:

22.04.2013
Now we can send signal with one args the next method:

object.SendSignal(SignalEnum.Signal);

Sample:

"Hello, World!".SendSignal(Signals.HelloWorldSignal);

30.05.2013

Add late binding.
We can write next code:

public class ClassA
{
    void TestLateBind(string obj)
    {
        Console.WriteLine(obj);
    }
}

//------------------
ClassA a = new ClassA();
rtSignalCore.AppendMethod(SignalMethodType.SignalHandler, a, "TestLateBind", "SignalForTestLateBinding");
"Hello, world".SendSignal("SignalForTestLateBinding");
//------------------

Console output:
Hello, world

Project Admins:


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.