Click here to Skip to main content
14,447,320 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: WSO CCC OTD 2019-04-02 - we have a winner! Pin
pkfox2-Apr-19 2:19
professionalpkfox2-Apr-19 2:19 
GeneralRe: WSO CCC OTD 2019-04-02 - we have a winner! Pin
Randor 2-Apr-19 3:15
professional Randor 2-Apr-19 3:15 
GeneralRe: WSO CCC OTD 2019-04-02 - we have a winner! Pin
pkfox2-Apr-19 4:06
professionalpkfox2-Apr-19 4:06 
GeneralIs there an ambitious coding project you'd like to take on? Pin
honey the codewitch1-Apr-19 19:16
mvahoney the codewitch1-Apr-19 19:16 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
Jon McKee1-Apr-19 19:52
professionalJon McKee1-Apr-19 19:52 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
honey the codewitch1-Apr-19 20:08
mvahoney the codewitch1-Apr-19 20:08 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
Jon McKee1-Apr-19 20:25
professionalJon McKee1-Apr-19 20:25 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
honey the codewitch1-Apr-19 21:04
mvahoney the codewitch1-Apr-19 21:04 
If you want performance, and are using the socket apis directly, they don't directly use the task framework in .NET

here's a wrapper to help with that

// from https://blogs.msdn.microsoft.com/pfxteam/2011/12/15/awaiting-socket-operations/
		internal sealed class SocketAwaitable : INotifyCompletion
		{
			private readonly static Action _sentinel = () => { };

			internal bool _wasCompleted;
			internal Action _continuation;
			internal SocketAsyncEventArgs _eventArgs;

			public SocketAwaitable(SocketAsyncEventArgs eventArgs)
			{
				if (null==eventArgs) throw new ArgumentNullException("eventArgs");
				_eventArgs = eventArgs;
				eventArgs.Completed += delegate
				{
					var prev = _continuation ?? Interlocked.CompareExchange(
						ref _continuation, _sentinel, null);
					if (prev != null) prev();
				};
			}

			internal void Reset()
			{
				_wasCompleted = false;
				_continuation = null;
			}

			public SocketAwaitable GetAwaiter() { return this; }

			public bool IsCompleted { get { return _wasCompleted; } }

			public void OnCompleted(Action continuation)
			{
				if (_continuation == _sentinel ||
					Interlocked.CompareExchange(
						ref _continuation, continuation, null) == _sentinel)
				{
					Task.Run(continuation);
				}
			}

			public void GetResult()
			{
				if (_eventArgs.SocketError != SocketError.Success)
					throw new SocketException((int)_eventArgs.SocketError);
			}
		}


Check out the related blog post.

It's worth your time.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
Rage2-Apr-19 0:58
professionalRage2-Apr-19 0:58 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
Daniel Pfeffer2-Apr-19 1:38
professionalDaniel Pfeffer2-Apr-19 1:38 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
Rage2-Apr-19 5:12
professionalRage2-Apr-19 5:12 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
Nelek2-Apr-19 5:05
protectorNelek2-Apr-19 5:05 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
honey the codewitch2-Apr-19 5:18
mvahoney the codewitch2-Apr-19 5:18 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
jeron12-Apr-19 5:06
Memberjeron12-Apr-19 5:06 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
Rick York2-Apr-19 5:43
mveRick York2-Apr-19 5:43 
JokeRe: Is there an ambitious coding project you'd like to take on? Pin
jeron12-Apr-19 6:27
Memberjeron12-Apr-19 6:27 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
Rick York2-Apr-19 7:42
mveRick York2-Apr-19 7:42 
GeneralRe: Is there an ambitious coding project you'd like to take on? Pin
jeron12-Apr-19 9:28
Memberjeron12-Apr-19 9:28 
GeneralThey must be insane Pin
Mycroft Holmes1-Apr-19 16:30
MemberMycroft Holmes1-Apr-19 16:30 
GeneralRe: They must be insane Pin
Ron Anders1-Apr-19 17:36
MemberRon Anders1-Apr-19 17:36 
GeneralRe: They must be insane Pin
Mycroft Holmes1-Apr-19 20:39
MemberMycroft Holmes1-Apr-19 20:39 
GeneralRe: They must be insane Pin
RickZeeland2-Apr-19 0:40
communityengineerRickZeeland2-Apr-19 0:40 
GeneralRe: They must be insane Pin
S Douglas2-Apr-19 9:42
professionalS Douglas2-Apr-19 9:42 
GeneralRe: They must be insane Pin
Mycroft Holmes2-Apr-19 14:01
MemberMycroft Holmes2-Apr-19 14:01 
GeneralRe: They must be insane Pin
S Douglas4-Apr-19 5:45
professionalS Douglas4-Apr-19 5:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.