Click here to Skip to main content
15,566,678 members
Home / Discussions / C#
   

C#

 
GeneralRe: About Async Event Pin
Super Lloyd18-Jul-16 17:57
Super Lloyd18-Jul-16 17:57 
GeneralRe: About Async Event Pin
Marc Clifton19-Jul-16 2:07
mvaMarc Clifton19-Jul-16 2:07 
GeneralRe: About Async Event Pin
Super Lloyd19-Jul-16 3:44
Super Lloyd19-Jul-16 3:44 
GeneralRe: About Async Event Pin
Marc Clifton19-Jul-16 2:50
mvaMarc Clifton19-Jul-16 2:50 
GeneralRe: About Async Event Pin
Richard Deeming19-Jul-16 2:55
mveRichard Deeming19-Jul-16 2:55 
AnswerRe: About Async Event Pin
Super Lloyd19-Jul-16 4:07
Super Lloyd19-Jul-16 4:07 
GeneralRe: About Async Event Pin
Super Lloyd19-Jul-16 4:19
Super Lloyd19-Jul-16 4:19 
GeneralRe: About Async Event Pin
Super Lloyd19-Jul-16 15:32
Super Lloyd19-Jul-16 15:32 
Stranger and stranger:

If I replace my original Source property implementation:
C#
public AlarmSource Source
{
    get { return source; }
    set
    {
        Func<Task> handler = () => Task.Run(() => Console.WriteLine(Name));
        if (source != null)
            source.AlarmReceived -= handler;
        source = value;
        if (source != null)
            source.AlarmReceived += handler;
    }
}
AlarmSource source;

With this one
C#
public AlarmSource Source
{
    get { return source; }
    set
    {
        if (source != null)
            source.AlarmReceived -= () => Task.Run(() => Console.WriteLine(Name));
        source = value;
        if (source != null)
            source.AlarmReceived += () => Task.Run(() => Console.WriteLine(Name));
    }
}
AlarmSource source;

I do have the same bug as you have (i.e. the event handler is not removed).
This is relatively strange and I don't quite know what is happening...
But it is now narrowed down to a pretty strange syntax issue...
A new .NET Serializer
All in one Menu-Ribbon Bar
Taking over the world since 1371!

GeneralRe: About Async Event Pin
Richard Deeming20-Jul-16 2:51
mveRichard Deeming20-Jul-16 2:51 
GeneralRe: About Async Event Pin
Super Lloyd20-Jul-16 3:08
Super Lloyd20-Jul-16 3:08 
GeneralRe: About Async Event Pin
Richard Deeming19-Jul-16 2:54
mveRichard Deeming19-Jul-16 2:54 
GeneralRe: About Async Event Pin
Super Lloyd19-Jul-16 3:55
Super Lloyd19-Jul-16 3:55 
QuestionHow can I run multiple powershell commands in a C#/powershell runspace? Pin
turbosupramk318-Jul-16 5:02
turbosupramk318-Jul-16 5:02 
QuestionRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
Richard MacCutchan18-Jul-16 5:22
mveRichard MacCutchan18-Jul-16 5:22 
AnswerRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
turbosupramk318-Jul-16 5:35
turbosupramk318-Jul-16 5:35 
GeneralRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
Richard MacCutchan18-Jul-16 5:51
mveRichard MacCutchan18-Jul-16 5:51 
GeneralRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
turbosupramk318-Jul-16 5:58
turbosupramk318-Jul-16 5:58 
GeneralRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
Richard MacCutchan18-Jul-16 7:15
mveRichard MacCutchan18-Jul-16 7:15 
GeneralRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
turbosupramk318-Jul-16 8:49
turbosupramk318-Jul-16 8:49 
GeneralRe: How can I run multiple powershell commands in a C#/powershell runspace? Pin
turbosupramk319-Jul-16 5:10
turbosupramk319-Jul-16 5:10 
QuestionClose Form Popup before opening MessageBox.Show and the form use delegate ? Pin
Member 245846717-Jul-16 23:47
Member 245846717-Jul-16 23:47 
AnswerRe: Close Form Popup before opening MessageBox.Show and the form use delegate ? Pin
OriginalGriff17-Jul-16 23:51
mvaOriginalGriff17-Jul-16 23:51 
Questionc# parser questions. Pin
elfenliedtopfan517-Jul-16 14:13
elfenliedtopfan517-Jul-16 14:13 
AnswerRe: c# parser questions. Pin
OriginalGriff17-Jul-16 22:42
mvaOriginalGriff17-Jul-16 22:42 
GeneralRe: c# parser questions. Pin
elfenliedtopfan518-Jul-16 4:31
elfenliedtopfan518-Jul-16 4:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.