pass to background thread

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ari

    #1

    pass to background thread

    hey all,

    i have a shared sub called WriteToErrorLog (msg as String) for obvious
    purposes. How do i send that to a background thread? i'm stuck on the part
    where thread.start executes a subroutine that doesn't accept parms (or can
    it?) how do i get the message parm into the background sub?

    2nd question: is this worth the trouble?

    thanks,
    ari
  • Cor Ligthert [MVP]

    #2
    Re: pass to background thread

    Ari,

    If you use a backgroundthrea d, than you should in my opinion forever think
    that it is meant to create a result to a foregroundthrea d.

    All other purposes of threading let mostly to no results. In those cases
    will services with their own thread work better.

    However mostly is using threads not worth the trouble. (Exept as you are
    sure that the background processes are acting really assynchroon).

    Just my thought,

    Cor

    "ari" <ari@discussion s.microsoft.com > schreef in bericht
    news:4BD00470-869B-4AA3-AF11-20583A89C8A6@mi crosoft.com...[color=blue]
    > hey all,
    >
    > i have a shared sub called WriteToErrorLog (msg as String) for obvious
    > purposes. How do i send that to a background thread? i'm stuck on the part
    > where thread.start executes a subroutine that doesn't accept parms (or can
    > it?) how do i get the message parm into the background sub?
    >
    > 2nd question: is this worth the trouble?
    >
    > thanks,
    > ari[/color]


    Comment

    • Brian Gideon

      #3
      Re: pass to background thread


      ari wrote:[color=blue]
      > hey all,
      >
      > i have a shared sub called WriteToErrorLog (msg as String) for obvious
      > purposes. How do i send that to a background thread? i'm stuck on the part
      > where thread.start executes a subroutine that doesn't accept parms (or can
      > it?) how do i get the message parm into the background sub?
      >[/color]

      There's already a lot of information out there on getting threads to
      pick up parameters. Just google for it.
      [color=blue]
      > 2nd question: is this worth the trouble?
      >[/color]

      No. I see no benefit in a background thread processing log messages.
      It would probably wind up being slower anyway. How much slower depends
      on how you implemented it. But that's not the worst of it. Threading
      just complicates the process of getting the error information to a log.
      The last thing you want to happen after an error occurs is losing that
      information because of another error in the logging code.
      [color=blue]
      > thanks,
      > ari[/color]

      Comment

      • ari

        #4
        Re: pass to background thread

        thanks very much for the feedback.

        "Brian Gideon" wrote:
        [color=blue]
        >
        > ari wrote:[color=green]
        > > hey all,
        > >
        > > i have a shared sub called WriteToErrorLog (msg as String) for obvious
        > > purposes. How do i send that to a background thread? i'm stuck on the part
        > > where thread.start executes a subroutine that doesn't accept parms (or can
        > > it?) how do i get the message parm into the background sub?
        > >[/color]
        >
        > There's already a lot of information out there on getting threads to
        > pick up parameters. Just google for it.
        >[color=green]
        > > 2nd question: is this worth the trouble?
        > >[/color]
        >
        > No. I see no benefit in a background thread processing log messages.
        > It would probably wind up being slower anyway. How much slower depends
        > on how you implemented it. But that's not the worst of it. Threading
        > just complicates the process of getting the error information to a log.
        > The last thing you want to happen after an error occurs is losing that
        > information because of another error in the logging code.
        >[color=green]
        > > thanks,
        > > ari[/color]
        >
        >[/color]

        Comment

        Working...