i have some code in an object constructor similar to
delegate DataSet MyInvoker;
public MyObject(Param1 p1)
{
// property sets here
// ...
BeginMyAsyncMethod();
}
public void BeginMyAsyncMethod()
{
// set some properties
// ...
MyInvoker inv = new MyInvoker(SomeBeginMethod);
inv.BeginInvoke(new AsyncCallback(SomeEndMethod), null);
}
My questions are:
- Is this generally considered bad practice?
- Would it be better (or good) practice to define a start method in my class which the user would call to carry out the async action?
This answer gives me the impression that leaving it to the user is bad practice although I am talking specifically about starting async methods in the constructor, not about the correct construction of an object.