tags:

views:

120

answers:

2

My WPF project utilizes the iTunes API. At start-up time, there's several background threads that work to load the iTunes library from the API into memory (this is for performance reasons once the app is running).

However, loading the library is painfully slow. On the order of nearly three minutes.

Most recently I've tried saving the library to a DataSet so load times would be quicker and I could just update the DataSet in the background once the app is running, however this did not really work either. It wouldn't properly save the DataSet.

I've also tried using a local MDF database, but that went wrong for reasons I can't remember either.

I think the main sticking point is that I need to save the iTunesLib.IITTrack COM object.

My question is, I guess, do you guys have any ideas on how I can load this library more quickly? I'm running out of ideas.

+1  A: 

However, loading the library is painfully slow. On the order of nearly three minutes.

Something is wrong with that loading time, I suggest you profile the code and find the problem, it's way above normal, either it's a bug in your code or in iTunes api.

I don't know about iTunes api, but becaust it's a COM api try to set the loading thread Tread.ApartmentState to STA, in case the iTunes api doesn't use a MTA thread (which is default for .net threads)

Pop Catalin
I switched them over to STA like so: this.Dispatcher.Thread.SetApartmentState(ApartmentState.STA);And nothing seemed to change. I can't imagine it's my code.. it's basically just a for loop that creates a Song object and adds it to a collection. I'm going to have to see if I can trim any fat.
Eric Smith
You can't set the ApartmentState on a thread once it's running, set it before the thread is created (if you create the tread yourself that is, if not, then try to create the loading thread yourself, and see if there are any changes).
Pop Catalin
I've seen lot's of weird issues with com objects not running on a STA thread, so this is my best guess.
Pop Catalin
I restructured my loading code and got it down to about 30s. Much more acceptable, probably still some improvements I can make.
Eric Smith
A: 

It has been my experience that the loading from the iTunes COM interface is a slow process. I've found that iTunes itself was the bottle neck and there isn't much that can be done.

epotter