Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8643113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:57:08+00:00 2026-06-12T11:57:08+00:00

I have a question about ThreadStart delegates in vb.net. I am taking over a

  • 0

I have a question about ThreadStart delegates in vb.net. I am taking over a senior programmer’s project, and he is much more experienced then myself so I’m kind of lost on what he was trying to do. I am trying to do some research on Threading but there is a lot out there on this topic and don’t want to waste my time with stuff that doesn’t pertain to my error here. I will post the whole exception message and hopefully someone can point me in the direction of an article that I could read to learn more about it.

System.InvalidOperationException was unhandled
  Message=The thread was created with a ThreadStart delegate that does not accept a parameter.
  Source=mscorlib
  StackTrace:
       at System.Threading.Thread.Start(Object parameter)
       at LabelLibrary.LabelPrinter.Print(PrintQueue queue) in C:\Documents and Settings\bjorandb\Desktop\LabelPrintingService\LabelTemplates\clsLabelPrinter.vb:line 94
       at LabelLibrary.LabelPrinter.Print() in C:\Documents and Settings\bjorandb\Desktop\LabelPrintingService\LabelTemplates\clsLabelPrinter.vb:line 53
       at PrintApplyApplication.HomeController.PrintThread.Print() in C:\Documents and Settings\bjorandb\Desktop\LabelPrintingService\PrintApplyApplication\Controllers\HomeController.vb:line 85
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

Here is the function that the error is getting thrown in, but I don’t know how much help it will be by itself.

Public Function Print(ByVal queue As PrintQueue) As PrintResult
    Dim result As PrintResult = Nothing
    Dim job As PrintSystemJobInfo = Nothing
    Dim thread As Threading.Thread = Nothing

    result = New PrintResult
    If queue Is Nothing Then
        result.Status = "Can not find printer " & queue.Name & "."
    ElseIf PrintFilePath Is Nothing Then
        result.Status = "Print File Path Cannot be nothing."
    Else
        Try
            thread = New Threading.Thread(AddressOf AddJob)
            thread.SetApartmentState(Threading.ApartmentState.STA)
            thread.Start(queue) <--- (Exception is being thrown here!!)
            result.Status &= "Print Sent Successfully"
        Catch ex As PrintJobException
            If ex.InnerException.Message = "File contains corrupted data." Then
                result.Status &= "Could not generate a label with given xps file. Check the xps file format and if it is corrupted."
            End If
            result.Status &= "There was an error printing."
            result.ErrorMessage = ex.Message
        End Try
        If queue.IsOutOfPaper Then
            result.Status &= "The printer is out of Paper."
        End If
        If queue.IsPaperJammed Then
            result.Status &= "The Printer is jammed."
        End If
        If (queue.IsOutOfMemory) Then
            result.Status &= "The Printer is out of memory."
        End If
    End If
    Return result
End Function

And here is the AddJob method

Private Sub AddJob()
    Dim job As PrintSystemJobInfo = Nothing

    Try
        job = LocalPrintServer.GetDefaultPrintQueue.AddJob("Text", PrintFilePath, False)
        job.Refresh()
        While Not (job.IsCompleted Or job.IsDeleted)
            job.Refresh()
        End While
    Catch ex As PrintJobException
    End Try
    If System.IO.File.Exists(PrintFilePath) Then
        System.IO.File.Delete(PrintFilePath)
    End If
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:57:09+00:00Added an answer on June 12, 2026 at 11:57 am

    Without the code I can only speculate that you’re creating the thread using ThreadStart and then calling the overload of Start that takes a parameter.

    You should either use ParameterizedThreadStart or simply call the Start method with no parameters.

    Edit: Like I said, the thread start method call is not compatible with the definition of AddJob. Simply use Thread.Start().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question about jqgrid, what the purpose of position:last in jqgrid? for more
I have question about this plugin system: .NET 4.0 ASP.NET MVC 3 plug-in architecture
I'm learning asp.net. I have question about example buttons I can use two types
I have question about managing transaction in asp.net application. For example i have application
I have questions about System.Threading.ThreadStart Class : where can I find its specifications (
I have question about parsing in Html helper : I have sth like: @foreach
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass
I have question about XSLT1.0. The task is to write out in HTML all
I have question about normalization. Suppose I have an applications dealing with songs. First
I have question about interpreting strings as packed binary data in C++. In python,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.