Abnormal swallow a problem

problem

In a method of Timer clock cycle, there is a foreachloop when the certain statement execution, will begin from scratch, rather than performing a subsequent statement.

analysis

The problem I have, after a preliminary analysis, the findings may be due to the program it appeared abnormal, but was swallowed caused. In my one item among the element, its value nullshould throw an empty exception. However, no exception is thrown, the follow-up I do not know where to swallow an exception, in the body of the loop adds a ifstatement to filter out the nullelements.

But then there will still be the most mentioned at the beginning of the problem, it seems that there are other places exception is thrown, the last investigation into the implementation of DevExpress chart control BeginDataUpdate()and EndDataUpdate()will have the symptoms later.

Check out my Timeris a reference to the realization of ABP Timer, find a place to call the callback method and found myself the exception caught and ignored.

private void TimerCallBack(object state)
{
    lock (_taskTimer)
    {
        if (!_running || _performingTasks)
        {
            return;
        }

        _taskTimer.Change(Timeout.Infinite, Timeout.Infinite);
        _performingTasks = true;
    }

    try
    {
        Elapsed?.Invoke(this, new EventArgs());
    }
    catch
    {
        // ignored
    }
    finally
    {
        lock (_taskTimer)
        {
            _performingTasks = false;
            if (_running)
            {
                _taskTimer.Change(Period, Timeout.Infinite);
            }

            Monitor.Pulse(_taskTimer);
        }
    }
}

According to the map view, I really callback code in the method throws an exception, leading to re-execute background tasks.

solve

After cross-thread access statement repaired, normal operating procedures, I also catch block behind which increases the exception log is written successfully solve the problem.

Guess you like

Origin www.cnblogs.com/myzony/p/11074427.html