# ExportData2 takes a longer time with each subsequent call

**URL:** <https://discuss.saleae.com/t/exportdata2-takes-a-longer-time-with-each-subsequent-call/1636>\
**Category:** Logic 1.x  (Legacy) Software\
**Created:** [June 12, 2022, 2:09am UTC](https://discuss.saleae.com/t/exportdata2-takes-a-longer-time-with-each-subsequent-call/1636 "2022-06-12T02:09:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve.auchschwelk](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@steve.auchschwelk](https://discuss.saleae.com/u/steve.auchschwelk)\
**Post date:** [June 12, 2022, 2:09am UTC](https://discuss.saleae.com/t/exportdata2-takes-a-longer-time-with-each-subsequent-call/1636/1 "2022-06-12T02:09:53Z")

</div>

I’m writing a simple c# program to save some csv data in a while loop. The time required for ExportData2 seems to increase with each call. Starts at about 300 ms, next call 600ms, 900 and so on. Any idea how to get around this?

while (true)  
{  
if (sample\_count % 2 == 0)  
{  
export\_settings.FileName = folder\_path + “cso\_capture1”;  
}  
else  
{  
export\_settings.FileName = folder\_path + “cso\_capture2”;  
}  
sample\_count++;

```
			Client.SetCaptureSeconds(5);
			Client.Capture(); //blocks until capture is complete, but processing is not complete.
			watch.Start();
			if (Client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
				throw new Exception("processing took too long");
			
			Client.ExportData2(export_settings, true, false);
			watch.Stop();
			Console.WriteLine($"Export Time: {watch.ElapsedMilliseconds} ms");
		}
```

---

<div class="post-metadata">

**Author:** ![timreyes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/timreyes/32/108_2.png) [@timreyes](https://discuss.saleae.com/u/timreyes)\
**Post date:** [June 13, 2022, 11:48pm UTC](https://discuss.saleae.com/t/exportdata2-takes-a-longer-time-with-each-subsequent-call/1636/2 "2022-06-13T23:48:22Z")

</div>

@steve.auchschwelk Hmm… I’m wondering if the increasing “watch” time is due to a backlog of data being processed, or if it is due to the actual export time by itself.

To help isolate the issue, could you run two tests below to see if you find any differences?

1. 

```auto
watch.Start();
if (Client.BlockUntillProcessingCompleteOrTimeout(new TimeSpan(0, 0, 5)) == false)
	throw new Exception("processing took too long");
watch.Stop();
			

```

1. 

```auto
watch.Start();
Client.ExportData2(export_settings, true, false);
watch.Stop();

```

---

<div class="post-metadata">

**Author:** ![timreyes](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/timreyes/32/108_2.png) [@timreyes](https://discuss.saleae.com/u/timreyes)\
**Post date:** [June 15, 2022, 9:57pm UTC](https://discuss.saleae.com/t/exportdata2-takes-a-longer-time-with-each-subsequent-call/1636/3 "2022-06-15T21:57:41Z")

</div>

@steve.auchschwelk I had another quick look at your code with the team here. You might need to call Reset() or Restart(). Can you check if that might be the issue?

> **[Stopwatch.Reset Method (System.Diagnostics)](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.stopwatch.reset?view=net-6.0)**
>
> Stops time interval measurement and resets the elapsed time to zero.

> **[Stopwatch.Restart Method (System.Diagnostics)](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.stopwatch.restart?view=net-6.0)**
>
> Stops time interval measurement, resets the elapsed time to zero, and starts measuring elapsed time.

---

<div class="post-metadata">

**Author:** ![markgarrison](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.saleae.com/markgarrison/32/23_2.png) [@markgarrison](https://discuss.saleae.com/u/markgarrison)\
**Post date:** [July 15, 2022, 9:59pm UTC](https://discuss.saleae.com/t/exportdata2-takes-a-longer-time-with-each-subsequent-call/1636/4 "2022-07-15T21:59:10Z")

</div>

We’ve just launched a preview of the new automation API for the Logic 2 software! You can find everything you need to get started here: [Saleae Logic 2 Automation API](https://discuss.saleae.com/t/saleae-logic-2-automation-api/1685)

---

<div class="post-metadata">

**Author:** ![steve.auchschwelk](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@steve.auchschwelk](https://discuss.saleae.com/u/steve.auchschwelk)\
**Post date:** [August 8, 2022, 2:07am UTC](https://discuss.saleae.com/t/exportdata2-takes-a-longer-time-with-each-subsequent-call/1636/5 "2022-08-08T02:07:46Z")

</div>

Thanks Tim and Mark. Had to go off and do another task for a while, but I’m back now and will try to test. Will also look at the new API.

---

<div class="post-metadata">

**Author:** ![steve.auchschwelk](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@steve.auchschwelk](https://discuss.saleae.com/u/steve.auchschwelk)\
**Post date:** [August 10, 2022, 1:42am UTC](https://discuss.saleae.com/t/exportdata2-takes-a-longer-time-with-each-subsequent-call/1636/6 "2022-08-10T01:42:47Z")

</div>

Thanks Tim. You were right. Much appreciated.
