Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Mutlithreading:-Playing Mutiple Video files CPU 100%

Mutlithreading:-Playing Mutiple Video files CPU 100%

Scheduled Pinned Locked Moved C#
cssquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leoiser
    wrote on last edited by
    #1

    Hi, I am doing an application that is using webservice & displaying data.So every 30 seconds the application will call webservice, I use system.Threading.Timer it is working fine.CPU usage is very less (maximum 30).I got an additional task to play video files.So it will be maximum 8 video in a screen (video files located in local system) & very 30 seconds according to data from ws video file will change.I write the code like this.In timer callback event I am Executing 2 functions [Code] System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(GetNextPage), state); // going 2 next page, in a page displaying 8 rows System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(GetNextVideo), state); // displaying corresponding video //in delegate of video I put the below code wmp = (AxWMPLib.AxWindowsMediaPlayer)Arrctrl[0]; //Find the control bcos adding at runtime thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(PlayCurrentWMP)); //PlayCurrentWMP is assign the URL & play thread.Priority = System.Threading.ThreadPriority.Lowest; thread.IsBackground = true; thread.Start(wmp); [/Code] Please advice what is wrong in my coding. Thanks in advance :confused:

    L 1 Reply Last reply
    0
    • L leoiser

      Hi, I am doing an application that is using webservice & displaying data.So every 30 seconds the application will call webservice, I use system.Threading.Timer it is working fine.CPU usage is very less (maximum 30).I got an additional task to play video files.So it will be maximum 8 video in a screen (video files located in local system) & very 30 seconds according to data from ws video file will change.I write the code like this.In timer callback event I am Executing 2 functions [Code] System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(GetNextPage), state); // going 2 next page, in a page displaying 8 rows System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(GetNextVideo), state); // displaying corresponding video //in delegate of video I put the below code wmp = (AxWMPLib.AxWindowsMediaPlayer)Arrctrl[0]; //Find the control bcos adding at runtime thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(PlayCurrentWMP)); //PlayCurrentWMP is assign the URL & play thread.Priority = System.Threading.ThreadPriority.Lowest; thread.IsBackground = true; thread.Start(wmp); [/Code] Please advice what is wrong in my coding. Thanks in advance :confused:

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Cant tell from what you told us. Some ideas/suggestions: - maybe movie takes more than 30 seconds - maybe you keep adding threads - add a thread counter; increment it at the beginning of the threaded method (PlayCurWMP) and decrement it at the end; show it all the time - maybe you are exhausting the ThreadPool - I would add logging in all relevant parts, so you get a history line of what is going on; - you even may try to correlate your CPU load (observed, or obtained programmatically) with that time line. :)

      Luc Pattyn


      try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


      L 1 Reply Last reply
      0
      • L Luc Pattyn

        Cant tell from what you told us. Some ideas/suggestions: - maybe movie takes more than 30 seconds - maybe you keep adding threads - add a thread counter; increment it at the beginning of the threaded method (PlayCurWMP) and decrement it at the end; show it all the time - maybe you are exhausting the ThreadPool - I would add logging in all relevant parts, so you get a history line of what is going on; - you even may try to correlate your CPU load (observed, or obtained programmatically) with that time line. :)

        Luc Pattyn


        try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


        L Offline
        L Offline
        leoiser
        wrote on last edited by
        #3

        hi, Thanks for the reply.When I start the application I am adding control runtime.If I try to play the movie suddenly CPU usage become 100% & the application runs very slowly. Can you suggest is it AxWMPLib.AxWindowsMediaPlayer taking the memory? Every 30 seconds I am updating the screen using Threading.Timer & delegates.So id the screen changes I need to change all the videos. Can you pls help me How I play video with out affecting my screen display & reduce the CPU usage?I am not good in threading.Please give the code... Thanks a lot..

        L 1 Reply Last reply
        0
        • L leoiser

          hi, Thanks for the reply.When I start the application I am adding control runtime.If I try to play the movie suddenly CPU usage become 100% & the application runs very slowly. Can you suggest is it AxWMPLib.AxWindowsMediaPlayer taking the memory? Every 30 seconds I am updating the screen using Threading.Timer & delegates.So id the screen changes I need to change all the videos. Can you pls help me How I play video with out affecting my screen display & reduce the CPU usage?I am not good in threading.Please give the code... Thanks a lot..

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          I dont have code for this. I gave you suggestions and ideas, that will be it. One more suggestion: make sure you dont have a thread touch a control it did not create (on old .NET, before 2.0) that may cause almost any anomaly; on .NET >= 2.0 it should give an InvalidOperationException with some cross-thread remark in the message. Thats all I can do for you. :)

          Luc Pattyn


          try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups