Questions tagged [conceptual]

Conceptual questions involve programming problems which are not related to program code itself, but with algorithm logic and program architecture.

364 questions
221
votes
6 answers

What's the difference between Task.Start/Wait and Async/Await?

I may be missing something but what is the difference between doing: public void MyMethod() { Task t = Task.Factory.StartNew(DoSomethingThatTakesTime); t.Wait(); UpdateLabelToSayItsComplete(); } public async void MyMethod() { var result =…
Jon
  • 38,814
  • 81
  • 233
  • 382
78
votes
14 answers

Post-increment and Pre-increment concept?

I don't understand the concept of postfix and prefix increment or decrement. Can anyone give a better explanation?
Saad Masood
  • 11,036
  • 9
  • 32
  • 40
75
votes
5 answers

Why is TaskScheduler.Current the default TaskScheduler?

The Task Parallel Library is great and I've used it a lot in the past months. However, there's something really bothering me: the fact that TaskScheduler.Current is the default task scheduler, not TaskScheduler.Default. This is absolutely not…
62
votes
4 answers

Abstract Class vs. Interface

I have searched around SO as well as the rest of the web for a good answer but I have't found one that I really understand. I am going to present this in a different way and hopefully the answers will help others as well. As far as I understand,…
nathanjosiah
  • 4,441
  • 4
  • 35
  • 47
48
votes
3 answers

What is the conceptual difference between SynchronizationContext and TaskScheduler

Stephen Toub blogged that Both SynchronizationContext and TaskScheduler are abstractions that represent a “scheduler”, something that you give some work to, and it determines when and where to run that work. There are many different forms of…
41
votes
13 answers

Real Life Examples For CountDownLatch and CyclicBarrier

One example is given by one of our trainers when he was explaining difference between CountDownLatch and CyclicBarrier. CountDownLatch: Suppose a stone can be lifted by 10 people so you will wait for all 10 to come. Then only you can lift the…
Sunny Gupta
  • 6,929
  • 15
  • 52
  • 80
39
votes
5 answers

REST API Design: Nested Collection vs. New Root

This question is about optimal REST API design and a problem I'm facing to choose between nested resources and root level collections. To demonstrate the concept, suppose I have collections City, Business, and Employees. A typical API may be…
Alex
  • 75,813
  • 86
  • 255
  • 348
35
votes
1 answer

What is the difference between SynchronizationContext.Send and SynchronizationContext.Post?

Thanks to Jeremy Miller's good work in Functional Programming For Everyday .NET Development, I have a working command executor that does everything I want it to (do heavy lifting on the thread pool, send results or errors back to the synchronization…
flipdoubt
  • 13,897
  • 15
  • 64
  • 96
30
votes
2 answers

Understanding context in C# 5 async/await

Am I correct that async/await itself has nothing to do with concurrency/parallelism and is nothing more than continuation-passing style (CPS) implementation? And the real threading is performed by SynchronizationContext instance that await…
UserControl
  • 14,766
  • 20
  • 100
  • 187
29
votes
3 answers

How to show usage of static methods UML Class Diagram

How do i show the use of static methods in a UML class diagram? class A{ public static void test(){ } } class B{ public void b(){ A.test(); } } How would a class diagram look like, which shows the relationship? UML 2.0 would…
Nicolas
  • 950
  • 1
  • 7
  • 15
27
votes
3 answers

How to force subclasses to set a variable in java?

I have a class which defines all of the basic parameters for a given screen. From here every screen in the application is a subclass of this. I need every screen (i.e. subclass) to set the value of a variable in its implementation (namely, each…
btalb
  • 6,937
  • 11
  • 36
  • 44
26
votes
1 answer

The async and await keywords don't cause additional threads to be created?

I'm confused. How can one or many Task run in parallel on a single thread? My understanding of parallelism is obviously wrong. Bits of MSDN I can't wrap my head around: The async and await keywords don't cause additional threads to be created.…
24
votes
3 answers

Finding items in an universal hash table?

If items are organized randomly, how does the table know where to start looking? In a non-random table items are organized according to some characteristic. (i.e. name). So if the table needs to look up some arbitrary information about "John", it…
fdh
  • 5,256
  • 13
  • 58
  • 101
22
votes
3 answers

Why aren't method references singleton?

In Java, the following code returns false on both queries. Why? Wouldn't it be simpler for method references to be singleton? It would certainly make attaching and detaching listeners a lot simpler. As it is you need to keep a constant for any…
Dimitriye98
  • 207
  • 2
  • 10
22
votes
3 answers

I/O performance - async vs TPL vs Dataflow vs RX

I have a piece of C# 5.0 code that generates a ton of network and disk I/O. I need to run multiple copies of this code in parallel. Which of the following technologies is likely to give me the best performance: async methods with await directly use…
1
2 3
24 25