Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make event firing thread-safe #4

@jakesee

Description

@jakesee

Hi, Possibly a minor point, but the event firing could be more thread-safe by copying the handler to a local variable and then firing the local variable. This prevents potential issues where while the task is firing a separate thread adds or removes more handlers before the event is complete. It's an edge case, but as nobody can know how this control may be used anything is possible. For example, OnTaskMouseDoubleClick would look like:

private void OnTaskMouseDoubleClick(TaskMouseEventArgs e)
{
	EventHandler<TaskMouseEventArgs> locum = TaskMouseDoubleClick;
	if(locum != null)
	{
		locum(this, e);
	}
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions