Tech Off Post

Single Post Permalink

View Thread: is 'new object().property' or 'new object().method()' a good idea?
  • User profile image
    Curt Nichols

    evildictaitor wrote:
    To protect against it you could do

    MyObject o = new MyObject();
    var result = o.LongRunningMethod();

    But in fairness this is a bug that should be fixed by Microsoft rather than coded around, and you should write an bugreport if you find in your code that this is happening.

    You could use KeepAlive, but it's probably better to fix the design of your code. This is definitely not a bug. Smiley