none
computer hang up RRS feed

  • Question

  • I have a PowerPoint presentation with 1 picture on it. Not a normal inserted picture, but a picture that is linked to a picture file. Then in VSTO I update the content of picture continuously where it should run continuously and display all images of a given folder (dynamically).

    I have this code below. It works but the problem is that my computer becomes unstable after running e.g. 1 night or 1 weekend. I let it running for the weekend and then i stopped the slideshow. Then the computer is doing something, I guess clean up. My 32GB RAM is used for 50% and CPU is running at 50%. During this ending process (I left it running for 4 hours before I decided to reboot), I hardly can use my computer. Opening a web page takes 4 to 5 minutes. Opening a PDF document is not possible. Looks like my complete computer is locked...

    What might be happening and how to avoid?

    Project and test images: https://1drv.ms/u/s!AumRZ4Qd6Vz0hL8IqZ0u7rhqeRHeOg


    Wednesday, September 13, 2017 6:04 AM

Answers

  • Hi Kurt,

    Thanks for more information.

    It seems to be related with updating msoLinkedPicture, I suggest you make a test with below code which will update the image of a normal shape.

    Public Class ThisAddIn
    
        Private WithEvents tmr As System.Timers.Timer
        Private runningslideshow As PowerPoint.Presentation
    
        Private Sub ThisAddIn_Startup() Handles Me.Startup
    
        End Sub
    
        Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
    
        End Sub
    
        Private Sub Application_SlideShowBegin(Wn As SlideShowWindow) Handles Application.SlideShowBegin
            Dim s As Microsoft.Office.Interop.PowerPoint.Shape
            s = Wn.Presentation.Slides(1).Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, 50, 50, 100, 100)
            s.Name = "Test"
            Try
                For Each sl As PowerPoint.Slide In Wn.Presentation.Slides
                    For Each sh As PowerPoint.Shape In sl.Shapes
                        If sh.Name = "Test" Then
                            UpdateImage(sh)
                        End If
                    Next
                Next
    
                runningslideshow = Wn.Presentation
                tmr = New System.Timers.Timer(500)
                tmr.AutoReset = False
                tmr.Start()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    
    
        End Sub
    
        Private Sub UpdateImage(ByVal sh As PowerPoint.Shape)
            Static number As Integer
            Dim folder As String = "C:\Users\Administrator\Desktop\updatepictures\"
    
            number = number + 1
            If number >= 10 Then
                number = 1
            End If
    
            Dim newvalue As String = folder & "num" & number & ".png"
            sh.Fill.UserPicture(newvalue)
        End Sub
    
        Private Sub tmr_Elapsed(sender As Object, e As ElapsedEventArgs) Handles tmr.Elapsed
            Try
                If runningslideshow IsNot Nothing Then
                    For Each sl As PowerPoint.Slide In runningslideshow.Slides
                        For Each sh As PowerPoint.Shape In sl.Shapes
                            If sh.Name = "Test" Then
                                UpdateImage(sh)
                            End If
                        Next
                    Next
                End If
    
            Catch ex As Exception
                MsgBox(ex.Message)
            Finally
                If tmr IsNot Nothing Then
                    tmr.Start()
                End If
            End Try
        End Sub
    
        Private Sub Application_SlideShowEnd(Pres As Presentation) Handles Application.SlideShowEnd
            tmr.Stop()
            tmr = Nothing
            runningslideshow = Nothing
        End Sub
    
    End Class
    

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 29, 2017 7:39 AM

All replies

  • Hi Kurt Dupont,

    I could not reproduce your issue after running your code for half hour. The code works well.

    However, I found that you did not close Timer after stopping slideshow so the tmr_Elapsed event would still be called again and again. I would suggest you close the Timer in the SlideShowEnd event and then do the test again.

        Private Sub Application_SlideShowEnd(Pres As Presentation) Handles Application.SlideShowEnd
    
            tmr.Stop()
    
            tmr = Nothing
    
            runningslideshow = Nothing
    
        End Sub

    Best Regards,

    Terry

    Thursday, September 14, 2017 6:21 AM
  • True, it works fine for a couple of hours. And your remark about ending the timer is correct and should be there, but that does not solve the problem.

    I've found out more: when I run this similar code as a PowerPoint macro presentation, then the problem does not occur. So, it should be related to .NET of VSTO.

    I left it running this night for some 7 hours and I had the problem again. Starting the calculator took 4-5 minutes. Memory and CPU not that extremely high. But I did notice in the Visual Studio diagnostic tools, that there the garbage collector marks were not present. Does that rings a bell?

    Tonight I will rerun it, and force the GC to happen. See what that will bring...

    Friday, September 15, 2017 9:54 AM
  • Not sure about the GC anymore. I'm calling the GC.collect and .waitforpending every 100 calls, but the system becomes irresponsive.

    Would it be possible to you to test this during a night or maybe dedicated on a virtual pc. I'm experiencing a slow system after some 4h.

    Friday, September 15, 2017 1:06 PM
  • Hi Kurt Dupont,

    >>But I did notice in the Visual Studio diagnostic tools, that there the garbage collector marks were not present.

    According to this description, I think you are using Visual Studio to debug running the add-in for one night, right? Would this issue be caused by running too long of the Visual Studio? I would suggest you use VS to build the project and run the function from PowerPoint application instead of using Visual Studio.

    >>I left it running this night for some 7 hours and I had the problem again.

    Why do you need run the function for so long time? I would suggest you stop the timer every hour and then start it again.

    Here is the step and i will have a test this night.

    Declare a global variable.

    Private hourNum As Integer

    Initialize the variable in SlideShowBegin event

    hourNum = Now.Hour

    Check if the hour has been changed at the beginning the tmr_Elapsed event

            If Not Now.Hour = hourNum Then
    
                hourNum = Now.Hour
    
                tmr.Stop()
    
           End If

    Best Regards,

    Terry

    Monday, September 18, 2017 9:45 AM
  • Thanks Terry,

    One night, I ran the VSTO without Visual Studio. >> Same result.

    The second night, I ran your suggestion with the timer.stop, and I did that every minute, not every hour. Same result.

    What is the outcome of your testing? Now I'm curious.

    Wednesday, September 20, 2017 10:02 PM
  • Hi Kurt Dupont,
    One night, I ran the add-in without Visual Studio, everything is OK.
    The second night, I did not the test result since the pc is forced to restart.
    Do you have loaded any other power point add-ins, if you have, please unload other add-ins.
    Besides, what's your office version and windows version? Do you install all updates? Have you tried test your project on other version of Office/OS?
    Best Regards,
    Terry


    Thursday, September 21, 2017 8:27 AM
  • At this time, no other add-ons were loaded.

    Win10

    Latest PowerPoint, version 16.0.8326.2107 32 bit

    I did not test it on another configuration (I did test on other computers, here and at client!) since this combination is a recent configuration where it should work.

    Terry, what was your configuration then?


    • Edited by Kurt Dupont Thursday, September 21, 2017 2:58 PM
    Thursday, September 21, 2017 8:35 AM
  • Hi Kurt Dupont,

    Sorry for late reply. I used same configuration as you, 16.0.8326.2107 32 bit and window 10.

    I would suggest you go to File->Feedback to submit a feedback for your issue.

    Besides, I'm wondering why do you need open the slideshow for whole night. Is there any workaround?

    Best Regards,

    Terry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 25, 2017 10:36 AM
  • Thanks for the info.

    I'm in that type of business where you don't use PowerPoint to display a sales presentation about your company for the next 50 minutes. I'm running a business where you use PowerPoint 24 hours as self-running information screens. Think about museums, schools, factories... and I don't need to run it at night. I just need to run it for a longer period without interruptions.

    Monday, September 25, 2017 10:50 AM
  • Hi Kurt Dupont,

    Does these pictures change frequently?

    If not, what about recording this process as a gif picture and then display it directly?

    Best Regards,

    Terry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 26, 2017 10:28 AM
  • Oh yes. Very often. 

    The location of the folder, and its images content, very and changes continuously. And the slideshow needs to keep running.

    Tuesday, September 26, 2017 11:20 AM
  • Hi Kurt,

    Is there anyone operate this computer?

    >> During this ending process (I left it running for 4 hours before I decided to reboot), I hardly can use my computer.

    What do you mean by this? Do you mean the ending process waste for 4 hours?

    Do you close PowerPoint app before taking other actions?

    I suggest you make a test by disabling this add in, Show the Slide with image for the whole night, will the computer be unresponsive?

    With current code, if you replace UpdateImage code by writing txt files, will the computer be unresponsive?

    Best Regards,

    Edward 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 27, 2017 7:10 AM
  • Hi Edward,

    No one is operating the computer. It is some kind of information screen without presenter.

    4h long, I was barely able to open a new tab in my webbrowser, or during those 4h, it took 4 minutes to open the silly calculator. The system is slow, but the CPU (i7 intel) is only at 50% and using 50% of my 43GB ram.

    Without running the addin, the computer runs fine. It is due to this addin where I update the image source. That is the reason. When I comment that line and run the slideshow (without updating the images), all runs fine.

    Thursday, September 28, 2017 1:36 PM
  • Hi Kurt,

    Thanks for more information.

    It seems to be related with updating msoLinkedPicture, I suggest you make a test with below code which will update the image of a normal shape.

    Public Class ThisAddIn
    
        Private WithEvents tmr As System.Timers.Timer
        Private runningslideshow As PowerPoint.Presentation
    
        Private Sub ThisAddIn_Startup() Handles Me.Startup
    
        End Sub
    
        Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
    
        End Sub
    
        Private Sub Application_SlideShowBegin(Wn As SlideShowWindow) Handles Application.SlideShowBegin
            Dim s As Microsoft.Office.Interop.PowerPoint.Shape
            s = Wn.Presentation.Slides(1).Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, 50, 50, 100, 100)
            s.Name = "Test"
            Try
                For Each sl As PowerPoint.Slide In Wn.Presentation.Slides
                    For Each sh As PowerPoint.Shape In sl.Shapes
                        If sh.Name = "Test" Then
                            UpdateImage(sh)
                        End If
                    Next
                Next
    
                runningslideshow = Wn.Presentation
                tmr = New System.Timers.Timer(500)
                tmr.AutoReset = False
                tmr.Start()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    
    
        End Sub
    
        Private Sub UpdateImage(ByVal sh As PowerPoint.Shape)
            Static number As Integer
            Dim folder As String = "C:\Users\Administrator\Desktop\updatepictures\"
    
            number = number + 1
            If number >= 10 Then
                number = 1
            End If
    
            Dim newvalue As String = folder & "num" & number & ".png"
            sh.Fill.UserPicture(newvalue)
        End Sub
    
        Private Sub tmr_Elapsed(sender As Object, e As ElapsedEventArgs) Handles tmr.Elapsed
            Try
                If runningslideshow IsNot Nothing Then
                    For Each sl As PowerPoint.Slide In runningslideshow.Slides
                        For Each sh As PowerPoint.Shape In sl.Shapes
                            If sh.Name = "Test" Then
                                UpdateImage(sh)
                            End If
                        Next
                    Next
                End If
    
            Catch ex As Exception
                MsgBox(ex.Message)
            Finally
                If tmr IsNot Nothing Then
                    tmr.Start()
                End If
            End Try
        End Sub
    
        Private Sub Application_SlideShowEnd(Pres As Presentation) Handles Application.SlideShowEnd
            tmr.Stop()
            tmr = Nothing
            runningslideshow = Nothing
        End Sub
    
    End Class
    

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 29, 2017 7:39 AM
  • Hi Edward, 

    Thanks man, that did the trick. That workaround to fill the shape, completely solved my problem. Now I will go to implement this in my real program. Many thanks!

    • Marked as answer by Kurt Dupont Thursday, October 5, 2017 6:14 AM
    • Unmarked as answer by Kurt Dupont Thursday, October 5, 2017 8:50 AM
    Thursday, October 5, 2017 6:13 AM
  • Hi Kurt,

    I am glad the workaround works for you, would mind marking my reply as answer also?

    Then, others who run into the same issue would find solution easily.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 5, 2017 7:38 AM
  • Sure! I marked my answer as the solution but it should have been yours.

    Thanks.

    Thursday, October 5, 2017 8:51 AM