Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
65 3 2 8

SetupDataRequest - error: "Index was outside the bounds of the array"

Eikon Api 1.8.4.0

Hi,

I have a function which tries to request the last 50 bars. It works fine most of the times, but sometimes when there is a new request, I get "Index was outside the bounds of the array" as error message back. Any idea why that is?

"INTU.O error with hist request:" System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at ThomsonReuters.Desktop.SDK.DataAccess.TimeSeries.Impl.RequestBase.RegisterCallbacks()
   at ThomsonReuters.Desktop.SDK.DataAccess.TimeSeries.Impl.RequestBase.SendRequest()
   at ThomsonReuters.Desktop.SDK.DataAccess.TimeSeries.Impl.DataRequest.Send()

Do I need to cancel something or reset something after I received the data back to clear the array again?

if(tSRequest == null)
                tSRequest = DataServices.Instance.TimeSeries;
                
                DateTime dt = DateTime.Now;
                try
                {
                    requestEikon = tSRequest.SetupDataRequest(ric)
                    .WithView("TRDPRC_1")
                    .WithAllFields()
                    .To(new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, 0))
                    .WithInterval(CommonInterval.Intraday1Minute)
                    .WithNumberOfPoints(50)
                    .OnDataReceived(TSDataReceivedCallback)
                    .WithTimeZone(TimezoneType.Instrument)
                    .CreateAndSend();
               }
              catch(Exception ex)
                {
                    Console.WriteLine(ric + $" error with hist request: "+ ex);
                    return false;
                }
c#.neteikon-desktop-data-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
78.1k 246 52 72

@tt1057

According to the answer on StackOverflow, multiple threads may access the dictionary concurrently.

How does the application (on which thread) call the SetupDataRequest method? Is it the same thread that calls the OnDataServiceCreated callback method?



icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvote
65 3 2 8

Thank you for the direction. Yes, it is a few timers which might have fired at the same time, that may caused this. I ammended that and also added a lock() before the SetupDataRequest call.

I will test further if that fixes the issue

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvote
65 3 2 8

yes, I the lock() did the trick! thx for your support!

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.