• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 04:54
CET 09:54
KST 17:54
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Team Liquid Map Contest #22 - Presented by Monster Energy4ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13
Community News
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool22Weekly Cups (March 9-15): herO, Clem, ByuN win32026 KungFu Cup Announcement6BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains18
StarCraft 2
General
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Serral: 24’ EWC form was hurt by military service Weekly Cups (March 9-15): herO, Clem, ByuN win Team Liquid Map Contest #22 - Presented by Monster Energy Weekly Cups (August 25-31): Clem's Last Straw?
Tourneys
- nuked - KSL Week 87 [GSL CK] #2: Team Classic vs. Team Solar 2026 KungFu Cup Announcement [GSL CK] #1: Team Maru vs. Team herO
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death Mutation # 515 Together Forever
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ JaeDong's form before ASL Gypsy to Korea ASL21 General Discussion BSL Season 22
Tourneys
Small VOD Thread 2.0 [Megathread] Daily Proleagues [BSL22] Open Qualifiers & Ladder Tours IPSL Spring 2026 is here!
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Zealot bombing is no longer popular?
Other Games
General Games
Nintendo Switch Thread Path of Exile General RTS Discussion Thread Stormgate/Frost Giant Megathread Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Mexico's Drug War Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread Formula 1 Discussion Tokyo Olympics 2021 Thread General nutrition recommendations Cricket [SPORT]
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 3664 users

C# programming help?

Blogs > Phyre
Post a Reply
Phyre
Profile Blog Joined December 2006
United States1288 Posts
Last Edited: 2009-10-28 22:02:39
October 28 2009 22:01 GMT
#1
Just to get it out of the way, this isn't a homework thread. I've been out of school for quite some time now. If this somehow breaks a TL rule though, I'm sorry and I'll happily accept this being removed. That said...

I'm having a great deal of difficult figuring out how to redirect standard output of a running windows service to a simple console app. This is being done in C#. The service is really simple, it just console.writelines some text every few seconds. I want my console app to simply echo the service's output.

I got standard output redirection working just fine when redirecting output from one console app to another console app. Doing that for a service is proving difficult.

I used this to redirect from one console app to another: http://www.c-sharpcorner.com/UploadFile/edwinlima/SystemDiagnosticProcess12052005035444AM/SystemDiagnosticProcess.aspx

Doesn't seem like I can apply that to a service though as far as I can tell.

"Oh no, I got you with your pants... on your face... That's not how you wear pants." - Nintu, catching 1 hatch lurks.
prOxi.swAMi
Profile Blog Joined November 2004
Australia3091 Posts
October 28 2009 23:08 GMT
#2
Just out of curiosity, why would you want a service to have any visual aspects anyway? If you need visual aspects, a service is probably not the right solution to the problem...
Oh no
b3h47pte
Profile Blog Joined May 2007
United States1317 Posts
Last Edited: 2009-10-28 23:23:49
October 28 2009 23:22 GMT
#3
i wrote a service before which communicated with an app on the desktop. One viable option on C++ i believe was to use SendMessage() - part of the Win32 API - to send messages from the service to the application. However the option I ended up using as SendMessage wasn't exactly passing parameters correctly, was i had the computer essentially send UDP packets to itself... definitely not your most ideal solution but it works. Since you're using C# i'm going to assume that the .NET framework has some networking solution so you can use that.

So in your service you would have a loop or function or however you implement it that sends a data packet to your computer's ip address (127.0.0.1) and a specific port and just have the console app listen on that port for any packets and open the packet, get the string, and print the string.

That's atleast the way I would probably do it.
As i said before, this is most likely NOT the best way to do it as i'm sure .NET has other ways of accomplishing this but rather this is the way I've done in the past (granted using C++..) and I know works.

I hope i answered your question and good luck! :3
prOxi.swAMi
Profile Blog Joined November 2004
Australia3091 Posts
October 29 2009 01:22 GMT
#4
Surely you don't need to use networking... I'm sure you can do what you're trying to do using Win32 interop
Oh no
b3h47pte
Profile Blog Joined May 2007
United States1317 Posts
October 29 2009 02:39 GMT
#5
Yes i know but i'm just saying it is an option although probably not the most viable one.
Phyre
Profile Blog Joined December 2006
United States1288 Posts
October 29 2009 03:19 GMT
#6
On October 29 2009 08:08 prOxi.swAMi wrote:
Just out of curiosity, why would you want a service to have any visual aspects anyway? If you need visual aspects, a service is probably not the right solution to the problem...

Well, we had a server program that could either run as a console app or as a service. Running as a console app we could see what the server is doing via console output but had the disadvantage of shutting down if someone accidentally logged off, remote desktop'ed in, etc. If we run it as a service we get around those accidental interruption problems but then we can't check to see what's going on.

So the solution I was tasked with making is a C# front end that can start the original program as a service and then read the console output from it. Thus the C# front end could go down due to someone logging off but that wouldn't affect the service and if we ever need to check up on the server we just bring the front end back online so we can see the console output.

I'm not sure if that is the optimal solution but that is what I was told to make.
"Oh no, I got you with your pants... on your face... That's not how you wear pants." - Nintu, catching 1 hatch lurks.
MasterOfChaos
Profile Blog Joined April 2007
Germany2896 Posts
October 29 2009 09:07 GMT
#7
Why don't you simple write the service so it logs it's output to a file? You might even be able to do that by piping stdout to the file.
LiquipediaOne eye to kill. Two eyes to live.
Phyre
Profile Blog Joined December 2006
United States1288 Posts
Last Edited: 2009-10-29 15:44:58
October 29 2009 15:00 GMT
#8
On October 29 2009 18:07 MasterOfChaos wrote:
Why don't you simple write the service so it logs it's output to a file? You might even be able to do that by piping stdout to the file.

The service already does log it's output to a file. Another reason for the new front end is to make the console output more readable via color coding and filtering options. Pretty sure color coding can be done on a console app as well, but as far as I know filtering the output isn't so easily done in a console app.
"Oh no, I got you with your pants... on your face... That's not how you wear pants." - Nintu, catching 1 hatch lurks.
Phyre
Profile Blog Joined December 2006
United States1288 Posts
Last Edited: 2009-10-29 17:59:12
October 29 2009 15:59 GMT
#9
Little change in plans. The service is apparently not using console.writeline(), rather it is writing to an eventlog. I'm not familiar with the use of event logs, time to start reading up on that. Not sure if this makes things easier or harder.

If anyone has any ideas on how to grab the event log output from a C++ service and output that to a C# frontend it would be much appreciated.

Edit: Yeah, this event log stuff seems like it will make life a lot easier. Sorry for the mixup guys, thanks for the help.
"Oh no, I got you with your pants... on your face... That's not how you wear pants." - Nintu, catching 1 hatch lurks.
garista
Profile Joined January 2003
Germany165 Posts
October 29 2009 20:46 GMT
#10
Use Microsoft's Log Parser, it can read text files but also the "Windows Event Viewer such as System, Application, and Security", it can even be used remotely.
Disclaimer: I haven't used it, but that's what their website states.
Please log in or register to reply.
Live Events Refresh
Replay Cast
00:00
Code For Giants Cup LATAM #5
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 97
StarCraft: Brood War
Sea 2242
actioN 666
Killer 420
Dewaltoss 138
Leta 76
EffOrt 73
ToSsGirL 56
Sharp 45
Jaedong 29
Bale 26
[ Show more ]
hero 25
GoRush 20
soO 15
NotJumperer 9
Counter-Strike
Stewie2K1423
shoxiejesuss486
allub245
Super Smash Bros
Mew2King88
Other Games
singsing2479
ceh9418
Sick197
Fuzer 106
crisheroes76
NeuroSwarm55
Trikslyr23
Organizations
Other Games
gamesdonequick619
Dota 2
PGL Dota 2 - Main Stream163
StarCraft: Brood War
UltimateBattle 47
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• Berry_CruncH167
• LUISG 17
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Upcoming Events
KCM Race Survival
1h 6m
Protoss vs Terran
WardiTV Team League
3h 6m
Big Brain Bouts
8h 6m
LetaleX vs Babymarine
Harstem vs GgMaChine
Clem vs Serral
Korean StarCraft League
18h 6m
RSL Revival
1d 1h
Maru vs Zoun
Cure vs ByuN
uThermal 2v2 Circuit
1d 6h
BSL
1d 11h
RSL Revival
2 days
herO vs MaxPax
Rogue vs TriGGeR
BSL
2 days
Replay Cast
2 days
[ Show More ]
Replay Cast
3 days
Afreeca Starleague
3 days
Sharp vs Scan
Rain vs Mong
Wardi Open
3 days
Monday Night Weeklies
3 days
Sparkling Tuna Cup
4 days
Afreeca Starleague
4 days
Soulkey vs Ample
JyJ vs sSak
Replay Cast
5 days
Afreeca Starleague
5 days
hero vs YSC
Larva vs Shine
Kung Fu Cup
5 days
Replay Cast
5 days
The PondCast
6 days
WardiTV Team League
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-03-18
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
BSL Season 22
CSL Elite League 2026
RSL Revival: Season 4
Nations Cup 2026
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
CSL 2026 SPRING (S20)
CSL Season 20: Qualifier 1
Acropolis #4
IPSL Spring 2026
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
NationLESS Cup
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.