i have Winform application who run all the files within listbox,
i am using Pcapdotnet DLLs to send packets into my network adapter, the process is that i am taking Wireshark capture file and with this file send all the packets.
each file will run with BackgroundWorker and after it’s finished the next time in my listbox srart to run etc.
i added a Checkbox and when this Checkbox in checked state all the files run in the same time simultaneous.
when it’s running my application crash with error: Exception has been thrown by the target of an invocation in:
static void Main()
{
Adapters addr = new Adapters();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new mainWindow());
}
the error received in the last line (Application.Run(new mainWindow());)
this is my code who handle in simultaneous running:
for (int i = 0; i < listBoxFiles.Items.Count; i++)
{
string filePath = (string)listBoxFiles.Items[i];
playCount = 0;
BackgroundWorker bgWsim = new BackgroundWorker();
bgWsim.WorkerReportsProgress = true;
bgWsim.ProgressChanged += new ProgressChangedEventHandler(bgW_ProgressChanged);
bgWsim.DoWork += new DoWorkEventHandler(
(s3, e3) =>
{
while ((playCount < numberOfLoops) && (bContinuePlay)) //play the capture
{
for (int k = 0; (k < listBoxFiles.Items.Count) && (bContinuePlay); k++)
{
class = new myClass(filePath , playSpeed);
class.evePacketProgress += new class.dlgPacketProgress(
(progressCount) =>
{
bgWsim.ReportProgress(progressCount, class);
});
if (selectedAdapter != null)
{
bContinuePlay = class.playCapture(selectedAdapter._packetDevice);
}
playCount++;
Thread.Sleep((int)delay);
}
}
});
bgWsim.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
(s3, e3) =>
{
groupBoxSelect.Enabled = true;
groupBoxOptions.Enabled = true;
groupBoxInfo.Enabled = true;
btnPlay.Enabled = true;
}
);
bgWsim.RunWorkerAsync();
}
how can i debug this error and find the problem ?
error screenshot:
A ProgressBar has
MaximumandMinumumproperties that are used to define the range of values that it will accept (defaulting from 0 to 100). If you try to set theValueproperty to a number outside of the range, it, will throw an ArgumentException. See here.