I'm trying to create a Report in Excel with a Table that could have 60000 records so I already have a function for doing that and it works, the problem is that when the table actually has this amount of records it last too much and the application dies. The solution I thought is putting that function in a Thread and run it background but it seems that the Thread begins to execute and then it just stops. Here is how I do it:

First I create a txt file and check if it was created, if it was I create the thread to create the Excel file. This function also edits the value of a hidden field when it's done, this is because when the thread starts I switch to another View in the multiview control and with a timmer I check when the values of the hidden field is changed for me to know that the file is done.

Protected Sub ButtonExcel2003_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonExcel2003.Click
//This function saves a config file
//Here I check if the file was created
If File.Exists(Server.MapPath("./Downloads/Configs.txt")) Then
            //FillExcel creates the excel file
            Dim t As New Thread(New ThreadStart(AddressOf Me.FillExcel))
            //I have a Multiview Control, I want that while the excel file is being created show the view number 2 that says "creating"
            Me.MultiView.ActiveViewIndex = 2
        Catch ex As Exception
            Me.Label2.Text = ex.Message
        End Try
        MsgBox1.ShowMessage("Couldn't create the file")
    End If
End Sub

Related posts

Recent Viewed