I am trying to execute the error handling component class within my program but keep getting the following error message:
Error 1 The type arguments for method 'Marketplace.ErrorHandlingComponent.Invoke(System.Func, int, System.TimeSpan)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
I'm not sure what is meant by try specifying the type arguments explicitly.
MainWindow.xaml.cs
public void SetPlotList(int filterReference)
{
// Fill plot list view
List<PlotComponent.PlotList> plotList = PlotComponent.SelectPlotLists(filterReference);
// Find the plot list item in the new list
PlotComponent.PlotList selectPlotList =
plotList.Find(x => Convert.ToInt32(x.PlotId) == _focusPlotReference);
Dispatcher.Invoke(
(() =>
{
PlotListView.ItemsSource = plotList;
if (selectPlotList != null)
{
PlotListView.SelectedItem = selectPlotList;
}
}));
int jobSum = 0;
int bidSum = 0;
foreach (PlotComponent.PlotList item in PlotListView.Items)
{
jobSum += Convert.ToInt32(item.Jobs);
bidSum += Convert.ToInt32(item.Bids);
}
// Determine job/bid list ratio
Dispatcher.BeginInvoke(
new ThreadStart(() => JobBidRatioTextBlock.Text = jobSum + " jobs - " + bidSum + " bids"));
}
private void ValidateTextbox()
{
if (Regex.IsMatch(FilterTextBox.Text, "[^0-9]") || FilterTextBox.Text == "") return;
try
{
ErrorHandlingComponent.Invoke(() => SetPlotList(Convert.ToInt32(FilterTextBox.Text)), 3, TimeSpan.FromSeconds(1));
}
catch
{
FilterTextBox.Text = null;
}
}
ErrorHandlingComponent.cs
public static T Invoke<T>(Func<T> func, int tryCount, TimeSpan tryInterval)
{
if (tryCount < 1)
{
throw new ArgumentOutOfRangeException("tryCount");
}
while (true)
{
try
{
return func();
}
catch (Exception ex)
{
if (--tryCount > 0)
{
Thread.Sleep(tryInterval);
continue;
}
LogError(ex.ToString());
throw;
}
}
}