I am wanting to check to make sure that I am invoking methods that return void when a method only returns Task
and not Task<T>
.
I've got a helper method that it's signature looks like this:
internal async static Task DrawLeafMidrail(Graphics dc, float totalHeightFeet, List<HorizontalContainer> horizontals, bool showDetails, bool showVerticalDetails)
{
await Task.Run(() =>
{
float y, sl, startX, endX, stileWidth = 0, btmRailPx = 0, leftJmb;
PointF[] points;
List<VerticalContainer> verticals = new List<VerticalContainer>();
List<LineContainer> lines = new List<LineContainer>();
//..code omitted
});
}
And I am calling this helper method of Task like:
Horizontal.DrawLeafMidrail(
dc, doorPoints.BayRect.Height / Constants.PIXELS_PER_FOOT,
lstHors, ,forDoorDetail).Wait();
Notice that I've got .Wait()
appended to the end of the caller. I just want to make sure that this is the correct way and this will have the same effect as if the caller was to call the helper method like:
Task t = Horizontal.DrawLeafMidrail(dc, doorPoints.BayRect.Height / Constants.PIXELS_PER_FOOT, lstHors, i == 0, forDoorDetail);
t.Wait();