VB.NET Run existing functions in a background.

Posted on 2012-09-17
Medium Priority
Last Modified: 2012-09-17
Hi, I have some functions that are sending requests to my webserver in order to obtain data,
however when those functions are called, form is freezing up because it's not run via backgroundworker.

Now I need to know what is the easiest way to call them functions without freezing a form.

Function example:

    Public Sub PreSave()
            Dim response As New String(SendRequest("presavecheck.php?id=" & PCID & "&date=" & TodaysDate))
            If response = "SAVENEWRECORD" Then
            ElseIf response = "UPDATEEXISTINGRECORD" Then
            End If
        End Try
    End Sub

Open in new window

Maybe there is a way to create and start a backgroundworker with a functions name to run. For example:

so it would do whatever the function has to do and then after that I could run something like:

Thank you.
Question by:VAL1N
  • 2
LVL 83

Accepted Solution

CodeCruiser earned 2000 total points
ID: 38405095
You can use a thread instead and give it the name of the function to execute. It will execute the function and then just die.


Alternatively, you can call this function from backgroundworker's DoWork event handler.

Author Comment

ID: 38405116
Is it okay to define it once:

Private DataProcessingThread As Thread

and then run it multiple times like this:

DataProcessingThread = New Thread(AddressOf PreLoad)
        DataProcessingThread.IsBackground = True
        DataProcessingThread = New Thread(AddressOf PreSave)
        DataProcessingThread.IsBackground = True

Author Comment

ID: 38405120
My main concern is, if I will run it multiple times one after another, will it interrupt the previous operation?

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question