This project has moved. For the latest updates, please go here.

Think this needs some multi-threading...

Jan 5, 2011 at 10:05 PM

Great idea for an app this, and the functionality it provides is excellent.

 

I can't help but feel the UI could behave more responsively though, especially when doing a movie search.

It must be performing its processing in the same thread as the UI. Maybe you should consider spawning background threads for the expensive actions?

 

Happy to provide you with a class that I've been using for a few years that simplifies the process somewhat :)

 

Regards,

Westy

Jan 6, 2011 at 9:56 AM

G'day westy & welcome.

I'm pretty sure that that is the case already.... If I get MC to "check for new movies", it actually does the scraping in another thread so that you can continue navigating the rest of the GUI. New movies or Tv shows will populate the lists as they are scraped.

One of the other developers may be able to explain how much is done on the other thread as I do not know that. There is two main parts that I see, scanning the folders for new files & then scraping those new files. I'm not sure if all of that is done on the separate thread or not. In addition maybe that thread needs a lower priority or thread slice to make the GUI a little smoother.

Can you explain what actions you are taking that causes an issue for you? 

Cheers

 

 

Jan 6, 2011 at 12:28 PM

Hi there.

Just something I noticed last night when using the application for the first time... as soon as I clicked "Scan for new movies" (or whatever it was, sorry, at work atm) then the UI hung completely, and was non-responsive until that batch completed, or was killed in task manager.

 

I'm pretty sure it's doing stuff in the UI thread, since if it was in a background thread then the UI would/should not hang.

It would be nice, for example, to be able to have a scan running in the background, but still be able to find/update posters and fan art in the foreground.

 

Oh, and apologies for posting here and not on the 'main' forums; just have an account here so thought I may aswell get the ball rolling :)

 

Cheers,

Westy

Jan 6, 2011 at 9:06 PM

are you using the latest release 3.400? What OS are you using? 32/64 bit? I can select Movies > Search For New Movies & I can still navigate around the GUI.....

Cheers

Jan 6, 2011 at 9:16 PM

Hi again.

 

Yes, I am running the latest release.

Seems a lot better on my 6 core desktop than it did on my Macbook Pro, so maybe that was it.

 

Great piece of software :)

 

Seem to be having a few other issues though; namely:

  • Doesn't like bluray disk structures;
  • or HD-DVD's;
  • Puts everything for DVD's under the VIDEO_TS folder, although this doesn't seem too much of an issue.

Trying to scan the missus's exercise DVD's atm, and seems to be getting a few of them. Might be nice to have a lovefilm scraper though, or amazon or something.

Just a thought.

 

Thanks for the response!

 

Cheers,

Westy

Jan 7, 2011 at 11:32 PM
Edited Jan 7, 2011 at 11:33 PM

That is probably it because it runs fine on my single core Athlon 64... 

re the bluray structure, I think you are right, I don't think MC will recognise any of those file extensions....

Below is a link to the structure information of both Bluray & HD-DVD. We should be able to incorporate this in a later release if its along the same lines as DVD's.

http://www.videohelp.com/hd

Cheers

 

 

Jan 10, 2011 at 2:01 PM
Edited Jan 10, 2011 at 3:55 PM
StormyKnight wrote:

G'day westy & welcome.

I'm pretty sure that that is the case already.... If I get MC to "check for new movies", it actually does the scraping in another thread so that you can continue navigating the rest of the GUI. New movies or Tv shows will populate the lists as they are scraped.

One of the other developers may be able to explain how much is done on the other thread as I do not know that. There is two main parts that I see, scanning the folders for new files & then scraping those new files. I'm not sure if all of that is done on the separate thread or not. In addition maybe that thread needs a lower priority or thread slice to make the GUI a little smoother.

Can you explain what actions you are taking that causes an issue for you? 

Cheers


I think I know what he might be referring to. When initially adding a new movie root folder it grinds a bit before allowing you to move

to the other tabs.

I assumed it was because I have so many movies and it`s first connection to the internet when it starts scanning. It`s almost always been like that.

 

Jan 11, 2011 at 6:20 AM

Ok I will have a look into it, Thanks.

Jan 18, 2011 at 12:11 AM

The problem may be related to the issue I reported on the MC forum here;

http://billyad2000.darkbb.info/t1308-3400-crashes-after-loading-280-tv-series-folders


If the TV Show listing has already been built, so there are no new shows to scrape from a newly added root folder, bckgrnd_tvshowscraper_DoWork() zooms through the folders so fast that it crashes the UI (System.StackOverflowException) after about 250 calls to;

                bckgrnd_tvshowscraper.ReportProgress(0, newtvfolders(0))

at the end of the subroutine.

Using the suggestion here

http://www.visualbasicask.com/visual-basic-general/ui-freezes-while-adding-large-number-of-records-inspite-of-using-backgroundworker--threading.shtml

I fixed it by changing it to

                Dim lastProgress As DateTime = Now
                If (Now - lastProgress).TotalMilliseconds >= 42 Then
                    bckgrnd_tvshowscraper.ReportProgress(0, newtvfolders(0))
                    lastProgress = Now
                    newtvfolders.RemoveAt(0)
                End If

 Which will limit calls to ReportProgress to about 22/second max.

You may be able to duplicate the problem by following the steps in my MC Forum Bug report, but as I mention there, I am using a 6 core AMD AND a solid state drive, so calls to ReportProgress() happen VERY fast. 

Coordinator
Jan 18, 2011 at 8:18 AM

Thanks for that input, I never would have found that myself, I have nowhere near enough TV Shows to raise this issue.

I'll implement the change if needed, but I would rather find the cause, is this a bug with .net, or have I used a bad method.

Jan 18, 2011 at 11:55 PM

You can use the steps from my MC forum post to replicate the error.  It should trigger it even on a slower drive/CPU

>

T:
MD TVBugchk
CD TVBugchk

Using notepad, create T:\TVBugchk\tvshow.nfo containing;

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><tvshow><title>Bug Test</title></tvshow>

Generate 500 folders, and copy tvshow.nfo to each folder;

T:\TVBugchk>for /L %a in (1,1,500) do xcopy tvshow.nfo %a\*.*

Then in MC, add T:\TVBugchk to list of root folders, click "Main Browser" then click "Check Roots For New TV Shows" from the "TV Shows" drop down menu.

>

The cause in general is triggering ReportProgress() more than 20ish times per second. The link I provided gives a general overview, but apparently it is a common problem, and the solutions are varied.

I also had to fix the issue in a few other places.   My CPU and solid state d speed exposed them I guess

.

Form1.vb.bckgrnd_tvshowscraper_DoWork()

...
Else
newtvshow.episodeactorsource = "imdb"
End If
newtvshow.sortorder = userprefs.sortorder
' KAS No UI objects can be manipulated in DoWork
' http://www.eggheadcafe.com/software/aspnet/29262040/backgroundworker-vs-threads.aspx
' This causes Form1 New() to fire
' User will have to search for new episodes after refresh (i guess)
' nfofunction.savetvshownfo(newtvshow.path, newtvshow, True)
If Not tvfolders.Contains(newtvfolders(0))
Then
tvfolders.Add(newtvfolders(0))
End
If
' KAS Prevent stack dump on more than 257ish series folders
While (Now - lastProgress).TotalMilliseconds < 42
' 23 times per second
Thread
.Sleep(2)
End
While
lastProgress = Now
bckgrnd_tvshowscraper.ReportProgress(0, newtvfolders(0))
newtvfolders.RemoveAt(0)
'bckgrnd_tvshowscraper.ReportProgress(0, newtvfolders(0))
'newtvfolders.RemoveAt(0)
Else
If Not tvfolders.Contains(newtvfolders(0))
Then
tvfolders.Add(newtvfolders(0))
End
If
tvfolders.Add(newtvfolders(0))
' KAS Prevent stack dump on more than 257ish series folders
While (Now - lastProgress).TotalMilliseconds < 42
' 23 times per second
Thread
.Sleep(2)
End
While
lastProgress = Now
bckgrnd_tvshowscraper.ReportProgress(0, newtvfolders(0))
newtvfolders.RemoveAt(0)
'bckgrnd_tvshowscraper.ReportProgress(0, newtvfolders(0))
'newtvfolders.RemoveAt(0)
End
If

Catch ex As
Exception
Finally
Try

Catch ex As
Exception

End
Try


End
Try

Else

'not to process

'...

If Not tvfolders.Contains(newtvfolders(0))
Then
tvfolders.Add(newtvfolders(0))

End
If

' KAS Prevent stack dump on more than 257ish series folders
While (Now - lastProgress).TotalMilliseconds < 42
' 23 times per second
Thread
.Sleep(2)

End
While

lastProgress = Now

bckgrnd_tvshowscraper.ReportProgress(0, newtvfolders(0))

newtvfolders.RemoveAt(0)
' bckgrnd_tvshowscraper.ReportProgress(0, newtvfolders(0))
' newtvfolders.RemoveAt(0)

End If

Loop

End  Sub

Jan 19, 2011 at 12:51 AM

Thanks gotaudio. I've just started to sit down a look at this. I'll keep you guys posted.