# Receiving and sending notifications from database

I'm not much familiar with Task Api programming in C#. Can anyone review my following code?

The following is a ElapsedEventHandler of a System.Timers.Timer. In this event, I'm getting pending notifications from database and sending them. After I send the notification, I update that notification in database by setting HasSent = true. We require our notifications to be sent as soon as possible. This is the reason, I'm updating HAsSent in a separate thread by using Task Api. I would like to know if this is a bad practise? Should I use this? If not then why?

protected void ProcessNotifications(object source, ElapsedEventArgs e)
{

try
{

{
{
try
{

{
{
{
});
}
}
}
catch (Exception ex)
{
AppLogger.LogException(ex);
}
}
}
}
catch (Exception ex)
{
AppLogger.LogException(ex);
}
finally
{
}
}

• Can you please post the rest of the code? – t3chb0t Jan 31 at 11:57

Should I use this?

NO

If not then why?

## Remarks

Starting with the .NET Framework 4.5, the Task.Run method is the recommended way to launch a compute-bound task. Use the StartNew method only when you require fine-grained control for a long-running, compute-bound task. .......

Which would end up as

//...omitted for brevity