I have
void foo1()
{
using(...){...}
}
void foo2()
{
using(...){...}
}
void foo3()
{
using(...){...}
}
and I have
void foo()
{
...
backgroundWorker.DoWork += (s, ev) =>
{
try
{
foo1();
foo2();
foo3();
}
catch (Exception ex)
{
// log ex
}
};
...
}
and I just read that using
blocks swallow exceptions. It there an elegant way to handle exceptions from foo1()
, foo2()
and foo3()
in foo()
. I don't want to have a try/catch inside of each using
block in the methods. I did stumble into this post where an extension method is suggested but I'm just checking to see if there is anything better.
FYI, Network disconnection causes the logic inside the using
block to throw an exception and that's what I'm trying to handle in one common place.
Thanks,