P
Piotrekk
Hi
I have created event to use it when user is pressing a button on the
joystick. In the parameters I need to pass states of all buttons. I
will need to call event subscribers each 1ms. For this purpose I have
created the following class.
class StateChangedEventArgs : EventArgs
{
static class States
{
public static byte x, y, select, start, a, b, c, d, z1,
z2;
//ButtonType is enum
public static ButtonType btn;
}
// PROPERTIES TO GET SET States values HERE
//constructor of event class
public StateChangedEventArgs(args)
{
// SET CURRENT VALUES
}
}
Delegate and event are:
private delegate void StateChanged(object sender,
StateChangedEventArgs e);
private event StateChanged a;
USAGE:
// called each 1ms
{
a(args);
}
Then the question. What do you think about performance of such an
operation. Is this ok that I create StateChangedEventArgs instance
each 1ms? I have made "States" internal class as static to avoid
creating to much data each 1ms. What are the good practics?
Kind Regards
Piotr Kolodziej
I have created event to use it when user is pressing a button on the
joystick. In the parameters I need to pass states of all buttons. I
will need to call event subscribers each 1ms. For this purpose I have
created the following class.
class StateChangedEventArgs : EventArgs
{
static class States
{
public static byte x, y, select, start, a, b, c, d, z1,
z2;
//ButtonType is enum
public static ButtonType btn;
}
// PROPERTIES TO GET SET States values HERE
//constructor of event class
public StateChangedEventArgs(args)
{
// SET CURRENT VALUES
}
}
Delegate and event are:
private delegate void StateChanged(object sender,
StateChangedEventArgs e);
private event StateChanged a;
USAGE:
// called each 1ms
{
a(args);
}
Then the question. What do you think about performance of such an
operation. Is this ok that I create StateChangedEventArgs instance
each 1ms? I have made "States" internal class as static to avoid
creating to much data each 1ms. What are the good practics?
Kind Regards
Piotr Kolodziej