I have a long running process, so I want to display a loading image while the job is processing and the hide the image when process completes.
Making the image visible when process starts works well, but hiding part doesn't work.

Here is the code-
This is image
HTML Code:
   <img id="loadingImage" src="../Images/ajax-loader.gif" style="visibility:hidden"  alt="Processing..."/>
and javascript code

HTML Code:
    <script type="text/javascript">

        function showImage() {
            document.getElementById('loadingImage').style.visibility = 'visible';
        }
        function hideImage() {
            document.getElementById('loadingImage').style.display = '';
        }  
</script>

I call it from my code behind page when user clicks button. First I call the showimage function, then call StartProcess in a thread. This part works beautifully. When StartProcess complete, I call hideImage method, but the image sill keeps displaying. I tried to put visibility ='hidden' OR style.display = '' but didn't work. Please advise
Code:
If (Not Page.ClientScript.IsStartupScriptRegistered("alert")) Then
            Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "showImage();", True)
        End If
        Dim NewThread As Thread = New Thread(AddressOf StartProcess)
        NewThread.Priority = ThreadPriority.Lowest
        NewThread.Start()
        StartProcess()


        If (Not Page.ClientScript.IsStartupScriptRegistered("alert")) Then
            Page.ClientScript.RegisterStartupScript(Me.GetType(), "alert", "hideImage();", True)
        End If