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

  • Home
  • SEARCH
  • 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 6937725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:24:03+00:00 2026-05-27T12:24:03+00:00

While trying to do something quite possibly beyond the means of PowerShell I seem

  • 0

While trying to do something quite possibly beyond the means of PowerShell I seem to have ran into a brick wall. I have a main form script, which orchestrates most of my functions but I need another script to open a listener (system.Net.Sockets.Udpclient.Receive) and keep feeding in information to a textbox in the main form throughout the entire program’s running.
For the life of me I can’t get around this daft non-child environment that jobs suffer from; no dot sourcing, no global scoped variables, nothing. I can put an object-listener on it for statechanged to completion and then open another listener and try and bodge this way but it will get very messy and unreliable.

As a workaround I would love a TCP/UDP listener which doesn’t hang the application for a response, an event to pull on hasmoredata or a way of updatign the textbox in the main script from within the job.

  • 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-05-27T12:24:03+00:00Added an answer on May 27, 2026 at 12:24 pm

    You can return data from a job by raising an event and forwarding it back to the local session.

    Here is an example:

     $job = Start-Job -Name "ReturnMessage" -ScriptBlock {
         # forward events named "MyNewMessage" back to job owner
         # this even works across machines
         Register-EngineEvent -SourceIdentifier MyNewMessage -Forward
    
         while($true) {
             sleep 2
             $i++
             $message = "This is message $i."
             # raise a new progress event, assigning to $null to prevent
             # it ending up in the job's output stream
             $null = New-Event -SourceIdentifier MyNewMessage -MessageData $message
         }
     }
    
    $event = Register-EngineEvent -SourceIdentifier MyNewMessage -Action {
        Write-Host $event.MessageData -ForegroundColor Green
    }
    
    <# Run this to stop job and event listner
    $job,$event| Stop-Job -PassThru| Remove-Job
    #>
    

    Note that you can still type at the prompt while the job is running. Execute the code in the block comments to stop the job and event listner.

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

Sidebar

Related Questions

All i have something i have been trying to do for a while and
While trying to do something a bit more complicated, I ran across a behavior
This is something that I have been trying to figure out for a while
I come across several problems while trying django unittests library. Something strange happens: I
I'm trying to do something like var=0 grep foo bar | while read line;
I've been whacking on this regex for a while, trying to build something that
While trying to use LINQ to SQL I encountered several problems. I have table
While trying to integrate Yahoo Media Player into my own website, I want to
I am trying to do something quite easy: fill an char** with arguments I
I'm quite new to Scala programming language, and was trying something out stucked in

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.