• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 18:44
CET 00:44
KST 08:44
  • 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
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament RSL Offline Finals Info - Dec 13 and 14! StarCraft Evolution League (SC Evo Biweekly) Sea Duckling Open (Global, Bronze-Diamond) $5,000+ WardiTV 2025 Championship
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night
Brood War
General
The top three worst maps of all time Foreign Brood War BGH Auto Balance -> http://bghmmr.eu/ Data analysis on 70 million replays BW General Discussion
Tourneys
Small VOD Thread 2.0 [Megathread] Daily Proleagues [BSL21] RO16 Group D - Sunday 21:00 CET [BSL21] RO16 Group A - Saturday 21:00 CET
Strategy
Current Meta Game Theory for Starcraft How to stay on top of macro? PvZ map balance
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile ZeroSpace Megathread The Perfect Game
Dota 2
Official 'what is Dota anymore' discussion
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
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
European Politico-economics QA Mega-thread US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread The Big Programming Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
I decided to write a webnov…
DjKniteX
Physical Exertion During Gam…
TrAiDoS
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1603 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
Patches Events
23:00
5.4k Patch Clash #9
Liquipedia
BSL 21
20:00
RO16: Group D
Bonyth vs StRyKeR
Tarson vs Dandy
ZZZero.O242
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft373
Liquid`TLO 226
elazer 180
CosmosSc2 127
ProTech123
SpeCial 70
StarCraft: Brood War
Shuttle 641
Artosis 477
ZZZero.O 242
NaDa 21
Terrorterran 2
Dota 2
Dendi1588
syndereN626
LuMiX2
League of Legends
Nathanias36
Heroes of the Storm
Khaldor195
Other Games
Grubby5941
shahzam591
XaKoH 95
Maynarde79
Mew2King73
fpsfer 2
Organizations
Other Games
EGCTV2270
gamesdonequick1753
BasetradeTV33
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Hupsaiya 60
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• Ler93
League of Legends
• Doublelift4101
Other Games
• imaqtpie2238
• Shiphtur231
Upcoming Events
Replay Cast
9h 17m
Wardi Open
12h 17m
StarCraft2.fi
16h 17m
Monday Night Weeklies
17h 17m
Replay Cast
1d
WardiTV 2025
1d 12h
StarCraft2.fi
1d 16h
PiGosaur Monday
2 days
StarCraft2.fi
2 days
Tenacious Turtle Tussle
3 days
[ Show More ]
The PondCast
3 days
WardiTV 2025
3 days
StarCraft2.fi
3 days
WardiTV 2025
4 days
StarCraft2.fi
5 days
RSL Revival
5 days
IPSL
5 days
Sziky vs JDConan
RSL Revival
6 days
Classic vs TBD
herO vs Zoun
WardiTV 2025
6 days
IPSL
6 days
Tarson vs DragOn
Liquipedia Results

Completed

Proleague 2025-12-04
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
Slon Tour Season 2
Acropolis #4 - TS3
WardiTV 2025
META Madness #9
Kuram Kup
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
RSL Offline Finals
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
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 © 2025 TLnet. All Rights Reserved.