Simplifying Asynchronous Programming with Microsoft Visual Studio Async CTP

Size: px
Start display at page:

Download "Simplifying Asynchronous Programming with Microsoft Visual Studio Async CTP"

Transcription

1 Simplifying Asynchronous Programming with Microsoft Visual Studio Async CTP Nelson Morais Universidade Lusófona de Humanidades e Tecnologias Campo Grande, Lisboa (Portugal) nelsonmorais@yahoo.com ABSTRACT Asynchronous Programming Model (APM) and Event-based Asynchronous Programming (EAP) have always been harder to consume and implement than the Synchronous Programming Model (SPM). Although Microsoft.NET Framework supported asynchronous programming since the first version of the library, and continually improved its usage, current patterns still break the control flow of the code and force the usage of callbacks or lambda expressions. This paper explores how Microsoft Visual Studio Async CTP proposes a new way to deal with this problem, introducing asynchronous methods and a new pattern entitled Task-based Asynchronous Pattern (TAP) that will bring the simplicity of the SPM pattern to the asynchronous programming models. Categories and Subject Descriptors D.3.3 [Programming Languages]: Language Constructs and Features abstract data types, polymorphism, control structures. General Terms Design, Standardization, Languages. Keywords SPM, APM, EAP, TAP, Asynchronous, Synchronous, Task, Visual Studio Async CTP. 1. INTRODUCTION For many years software running single threaded code has benefitted from the increase in clock rates of CPUs. No software changes were needed to make it run faster, since the increase of the processing capacity brought by a new CPU was enough to speed up almost any piece of code. In recent years we observed that this tendency is being replaced by increasing the number of CPUs or by adding more cores to a single CPU, reducing in some cases the clock rates of the CPU. In some of these scenarios this change brought a negative impact for single threaded software as the introduction of an extra CPU or core within a CPU with a lower clock speed leads to slower code processing and consequent performance degradation. Furthermore, the software wasn t taking any advantage of the new hardware in terms of processing capacity, the extra CPU or cores weren t used at all. Object oriented languages like C++, Java, Visual Basic.NET and C# provide support for the development of multi-threaded software, but most developers often opt to design and code single threaded code, as multi-threaded development requires higher programming skills and is more difficult to implement, test and debug. Currently the libraries inside the Microsoft.NET Framework use the Asynchronous Programming Model (APM) and the Eventbased Asynchronous Programming (EAP) to expose code that can run in a multi-threaded way, which its consumers can use to produce multi-threaded software using essentially the same patterns. But asynchronous programming using callbacks is difficult and with no language support, callback-based code inverts control, is awkward and is limited in expressivity [1]. As Mads Torgersen mentioned in [2] the problem is that these patterns are very disruptive to program structure, leading to complex and error prone code. As a consequence, developers give preference to a synchronous and simultaneously blocking approach with a negative impact in responsiveness and performance. In [3] Anders Hejlsberg spoke about the future of C# and Visual Basic and introduced the Visual Studio Async CTP [4] which has the goal of bringing asynchronous programming as close to the synchronous paradigm has possible [2]. This isn t new; in fact, a brief look at F# the Microsoft s most recent language shows that the concept brought by the Visual Studio Async CTP [4] is already there since 2007, and in fact C# and Visual Basic are now adopting a similar approach to handle the same problem [1]. This paper does an overview of the new Task-based Asynchronous Pattern (TAP) [5] and summarizes what the Visual Studio Async CTP [4] is. It will also show, how by using the Visual Studio Async CTP [4], most Synchronous Programming Model (SPM) focused developers, can get asynchrony while keeping the clarity and simplicity of the SPM that they are used to.

2 2. ASYNCHRONOUS PROGRAMMING 2.1 A new Trend Asynchronous programming is getting increasingly relevant in current and future programming languages; in fact it s becoming a norm in responsive and scalable apps [3]. For example, if we look at JavaScript and Silverlight one notices that they only provide asynchronous API s for handling their HTTP requests. Again, observing Microsoft s most recent language F# one can see the importance that asynchronous programming has had in the language design. In fact part of what we get with the Visual Studio Async CTP [4] in terms of asynchronous methods implementation was adopted from the design around asynchronous programming in F#. Asynchronous programming is getting extremely important as we create more applications that need to be connected to remote resources. In such connections, latency and response times increase substantially when compared to connections against local resources. If we look at UI software solutions we notice that the use of asynchronous programming has raised substantially in recent years, Web 2.0 applications or Rich Internet Applications (RIA) are just some examples where we can see asynchronous code on all HTTP server requests. Where server software is concerned, current architectures have increased the communications between services hosted at different machines, so the latency and responsiveness problems described earlier are also a concern in these situations. 2.2 Requirements for a pattern change Although in languages like Visual Basic, C# and others in which one can handle remote operations just like local calls, its usage should be done with care as the success of such execution might depend on several factors which are beyond the developer s control. Normally such calls represent a challenge to the developer, one has to decide whether the call is done synchronously (if there s an option to do it) or asynchronously. In the first case, we're probably faced with a lack of responsiveness and with a thread blocking issue because a remote call is being done, but, as the call is synchronous, the program structure isn't broken and the program code flows accordingly. On the other hand, if the option was to go with the asynchronous call, we no longer have the lack of responsiveness, but now we have greater complexity to deal with the result of the asynchronous call, as the current patterns provided by these languages will disrupt the program structure and make it harder to handle exceptions, just to mention a few of the problems. With the increasing demand for asynchronous programming, it was necessary to bring the simplicity of synchronous programming models to this programming paradigm. Developers need to be able to program their code using a synchronous flow, but at the same time be able to call asynchronous operations explicitly in a lightweight and non-disruptive manner [2]. This is the goal of the Visual Studio Async CTP [2]. 3. TASK-BASED ASYNCHRONOUS PATTERN Stephen Toub fully describes this new pattern in [5] and starts stating that this is a new pattern for asynchrony in the Microsoft.NET Framework. It is based on the Task and Task<TResult> types which are already used to represent arbitrary asynchronous computations. This new pattern is also meant to replace the previous patterns for asynchronous programming whenever the Microsoft.NET Framework is used. 3.1 Defining the TAP In contrast with the APM and the EAP, the TAP requires only one method to begin and complete an asynchronous operation. This is possible because the operation itself must return a Task or Task<TResult> depending on whether a void or a type TResult is expected. The input parameters of these methods should be the same as the synchronous version (if one exists) except for cases where out or ref parameters are specified, as these are not allowed and must be treated differently. Asynchronous methods using this pattern should not block the thread in which they are executed. The method should return the task as fast as possible and with a TaskStatus that has to be greater than Created, which for the task consumer means, the task has already been scheduled so calling Start in the task isn t required (in fact doing so will raise an exception). All exceptions that occur during the execution of an asynchronous method must be assigned to the task that will be returned, and the asynchronous method should not raise exceptions internally except for those that result of bad usage of the operation, like invoking the method with invalid values on its arguments. The implementation of the pattern optionally supports cancelation, and it s up to the consumers to use it. In such cases, overloaded methods should be created and a System.Threading.CancelationToken should be passed in an argument which by convention should be named cancelationtoken. Progress notification is also optionally included in the pattern. To support it, implementers should include an overload with an argument named progress of type IProgress<T>. As per the current version, one implementation of IProgress<T> is provided on a class named EventProgress<T> which implements the interface and also exposes a ProgressChanged event to be raised every time the asynchronous operation reports a progress update. Finally the method name of an asynchronous operation should be suffixed with the Async word (<MethodName>Async) to indicate to his consumers that it represents an asynchronous operation. An exception to this rule exists in the so called Combinators that represent asynchronous operations devoted purely to the creation, manipulation or combination of tasks, and where the method name or the type where he belongs are clear regarding its asynchrony. At the same time, the keyword async in C#, or Async in Visual Basic must prefix the method name to allow the compiler to identify which operations are meant to be modified by the later in order to implement the TAP. 3.2 Implementation of the TAP The Visual Studio Async CTP [4] brings to the C# and Visual Basic compilers the language support to implement the TAP. For this to happen two new keywords were introduced: async and await in C# and Async and Await in Visual Basic. With this two keywords both compilers are now able to translate a code with a synchronous semantic to an asynchronous execution by transforming the C# or Visual Basic source code to a TAP version on the compiled one. This was possible without changing the Microsoft.NET Framework library itself, it only needed to introduce a few more extensions on the assemblies provided by

3 the Visual Studio Async CTP [4] which in future versions of the library will by fully integrated within the existing types. The work was mostly done at the languages and compilers levels, as the core functionality was already in the library since the introduction of the Task and Task<TResult> types in version 4.0. Beside the support provided directly by the compilers, developers may also implement the TAP. In fact, by doing it, they have greater control on how the asynchronous operations are implemented. Both Compute-bound and I/O-bound asynchronous operations are well-suited to being exposed as TAP implementations [5]. For these, two types are especially suited for representing each kind of computation: types Task and Task<TResult> for Compute-bound operations; and the type TaskCompletionSource<TResult> for I/O-bound operations. By default the first will be scheduled for execution under the context of the ThreadPool either by executing a task with the Task.Run method (or equivalent Task.Factory.StartNew method), or from some Combinator like the ContinueWith method of an instance of a Task or Task<TResult>, the ContinueWhenAll and ContinueWhenAny methods from the TaskFactory. Besides asynchrony these cases will also get in-process parallelism, as a different thread (from the ThreadPool) will be used to effectively execute the computation while the calling thread will continue its work on the same process. For I/O-bound operations this should not be the case, as there s already an OS thread taking care of the I/O operation, there s no need to have a new thread in the process to handle these situations. Threads are expensive, so one should only use them when they re strictly necessary and there s no way to avoid it to reach an equivalent level of performance. In fact, what we want to do in these cases is to free up the calling thread until the I/Obound process is completed, and once it s done, continue the execution of the remaining code on the same thread. This is where TAP with the type TaskCompletionSource<TResult> comes in, as this type exposes a Task property which by default executes on the calling thread and who s life cycle is controlled by the methods SetResult, SetException, SetCanceled and the TrySet* methods. This scenario brings in-process asynchrony without the cost of the extra thread, while at the same time, we get out-process parallelism. 4. TRANSITION BETWEEN PATTERNS Currently there s a lot of code done using the current asynchronous programming paradigms. While we can t just throw way such implementations, we want to be able to get the benefits brought by the TAP and at the same time make this transition in a smooth way. To simplify this transition two patterns were defined. One was defined to transition from APM to TAP and another one to go from EAP to TAP. In fact, patterns to transition from TAP to the other two also exist, but these will not be covered here. 4.1 From APM to TAP Going from APM to APM is done in a simplified way, since there s a pattern which we can follow to do it. The pattern to go from APM to TAP is the following: 1. Create a new method who s name follows the TAP naming convention, which is: <OperationName>Async 2. Make sure the return type is of type Task or Task<TResult> 3. The method parameters should be: a. A type which implements the APM and who s operation is being wrapped to TAP b. The same list of parameters of the <OperationName>Begin method of the APM operation who is being wrapped to TAP 4. The body of the method should throw an ArgumentNullException exception if the APM type that was sent is null 5. The return of the operation is the result of using the static Factory.FromAsync method present in a Task or Task<TResult>, which returns a Task or Task<TResult> The following code from [5] shows an example of such a wrapper where the most relevant points are in bold: static Task<int> ReadAsync( Stream stream, byte[] buffer, int offset, int count) if (stream == null) throw new ArgumentNullException(); return Task<int>.Factory.FromAsync( stream.beginread, stream.endread, buffer, offset, count, null); In this example the Microsoft.NET Stream class which has SPM and APM implementations for the Read operation is being wrapped to implement TAP. For reference let s see the Read signatures of both the SPM (Read) and APM (BeginRead/EndRead) implementations: // Stream Read using the SPM pattern public int Read( byte[] buffer, int offset, int count); // Stream read using the APM pattern (Begin/End) public IAsyncResult BeginRead( byte[] buffer, int offset, int count, AsyncCallback callback, object state); public int EndRead(IAsyncResult asyncresult); Looking at the SPM, APM and TAP patterns we immediately see that the TAP signature is almost the same as the SPM, it differs only slightly in three points: 1. The return type changes from int to Task<int> 2. The name Changes from Read to ReadAsync

4 3. The first parameter in the TAP implementation Must be a parameter who s type implements the APM operation which is being wrapped If we compare both of the asynchronous implementations APM and TAP, we see that the TAP no longer needs to receive a callback to be invoked when the asynchronous execution ends, neither does it need the IAsyncResult and the <OperationName>End method to effectively retrieve the result of the asynchronous operation. All this is possible due to the fact that the TAP returns a Task or Task<TResult> which encapsulates the whole operation. Using this pattern, all types who expose operations using the APM pattern can be easily converted to the new TAP paradigm, so all the effort that was done to implement asynchronous programming using the APM isn t wasted, no matter if these types are inside the Microsoft.NET library itself or in its consumers. 4.2 From EAP to TAP Converting from EAP to TAP also follows a predefined pattern. A first look at this pattern might seem more complex than the previous one, but besides the fact that it requires a little more lines of code, the pattern itself is also quite simple. In fact, the first situation could also have been wrapped using the pattern showed below: The pattern to go from EAP to TAP is the following: 1. Create a new method who s name follows the TAP naming convention, which is: <OperationName>Async 2. Make sure the return type is of type Task or Task<TResult> 3. The method parameters should be the same list of parameters of the <OperationName>Async method of the EAP operation who is being wrapped to TAP 4. The body of the method should: a. Create an instance of the TaskCompletionSouce<TResult> class who s TResult must match the property Result of the <OperationName>CompletedEventArgs b. Create an instance of the type for which the EAP operation is being wrapped c. Handle the <OperationName>Completed event of instance created in 4b and do one of the following actions: i. Call the TrySetException of the instance created in 4a, passing the Error in the CompletedEventArgs ii. Call the TrySetCenceled of the instance created in 4a iii. Call the TrySetResult of the instance created in 4a, passing the Result in the CompletedEventArgs d. The corresponding previous action is done if: i. The property Error of the CompletedEventArgs isn t null ii. The property Canceled of the CompletedEventArgs is true iii. Otherwise e. Call the <OperationName>Async of the instance created in 4b passing the parameters received in 3 f. Finally return the Task of the TaskCompletionSouce instance created in 4a Here s an example from [5] of such a wrapper. Again the most relevant points are in bold: public Task<string> DownloadStringAsync(Uri url) var tcs = new TaskCompletionSource<string>(); var wc = new WebClient(); wc.downloadstringcompleted += (s, e) => if (e.error!= null) tcs.trysetexception(e.error); else if (e.cancelled) tcs.trysetcanceled(); else tcs.trysetresult(e.result); ; wc.downloadstringasync(url); return tcs.task; The example uses the WebClient class, which has an SPM and EAP implementations of the DownloadString operation. The SPM and EAP signatures are exposed bellow: // WebClient DownloadString using the SPM pattern public string DownloadString(Uri url); // WebClient DownloadString using the EAP pattern public void DownloadStringAsync(Uri url); public event DownloadStringCompletedEventHandler DownloadStringCompleted; public delegate void DownloadStringCompletedEventHandler( DownloadStringCompletedEventArgs e); public class DownloadStringCompletedEventArgs : AsyncCompletedEventArgs public string Result get; public class AsyncCompletedEventArgs : EventArgs public bool Cancelled get; public Exception Error get; // Remaing of the class ommited for simplicity As we can see, the EAP implementation is much more complex than the APM. The EAP model is based on the declaration of a <OperationName>Completed event to signal the completion of the asynchronous operation. As a consequence we need to define delegates for the event handlers and classes for the event arguments of such delegates. All of this makes the creation of the TAP wrapper a little trickier as all of these types are involved. Nevertheless, the EAP to TAP wrapper pattern is always the same so once it s understood it will be as simple to implement as it was for the APM. 5. ASYNCHRONOUS METHODS AND TAP As mentioned earlier the Visual Studio Async CTP [4] brings to C# and Visual Basic two new keywords: async (Async in Visual Basic) and await (Await in Visual Basic); these keywords bring the ability to create asynchronous methods in these languages. 5.1 The async and await keywords Asynchronous methods can be awaited when preceded by the new await keyword. In short, this keyword brings to these languages

5 the ability to do at the language level what was already possible to achieve at the API level through the usage of callbacks and Task s continuation methods. To be able to await a Task or Task<TResult> on the body of a method, the async keyword is required in the method declaration and it must precede the method name to signal to the compiler that the method is expecting asynchronous calls, which means TAP must be implemented by the compiler. Once the code reaches the await keyword a new task will be created and scheduled to execute the asynchronous method. After that, the method returns immediately to its caller and eventually provides a task to it (cases where the current asynchronous method returns a Task or a Task<TResult>). Once this is done, the thread continues its execution in the line of code that follows the current asynchronous method invocation while the remaining code after the awaited asynchronous operation will be executed once it completes, and most importantly, it will be executed on the context of the asynchronous invocation 1. Such asynchronous methods can return two distinct types: void, if there s no value to be returned; Task<TResult> or Task, otherwise. Typically the first case will be used to deal with event handlers where the approach is fire and forget. For those who return a Task<TResult> or a Task, its usage will mainly be for compositions with other asynchronous methods or Task s previously mentioned Combinators until the Task result is explicitly retrieved or the method is awaited in a void asynchronous method. To demonstrate a simple situation where all these cases can be illustrated let s see an example from [2] where there s a simple method whose purpose is to sum the sizes of the downloaded URI s. public int SumPageSizes( IList<Uri> uris) int total = 0; foreach (var uri in uris) string.format("found 0 bytes...", total); var data = new WebClient().DownloadData(uri); total += data.length; string.format("found 0 bytes total", total); return total; This simple method iterates a list of URI s, and for each one makes a web call to download data from a remote resource. While doing this download the current thread will be blocked while it waits the return from the remote call. This is clearly a situation that will benefit if the execution of such a remote call could be done asynchronously. The WebClient class already has a DownloadDataAsync 2 method which we can use to await the remote call and convert this synchronous method to an asynchronous method. As demonstrated bellow, the changes required to transform this synchronous method in an asynchronous one which uses the TAP are very straight forward. Essentially we need to start by changing the return value of the method from int to Task<int> and preceded the method return type with the new async keyword. Then, we just need to use the TAP version of the DownloadData which is the DownloadDataAsync and await this call. Here s the complete code transformation: public async Task<int> SumPageSizesAsync( IList<Uri> uris) int total = 0; foreach (var uri in uris) string.format("found 0 bytes...", total); var data = await new WebClient().DownloadDataAsync(uri); total += data.length; string.format("found 0 bytes total", total); return total; We can clearly see that the current code version now runs using an asynchronous pattern, while it keeps the control flow of the code and continues to maintain its readability in the same way it was in the synchronous version. This represents a major improvement and will certainly bring asynchronous programming to a level that was not seen before, as almost any developer will now be able to use asynchronous programming calls without the burden brought by the usage of the EAP or APM models. Further details on how this situation has to be implemented without the usage of TAP can be found on [2]. To continue on this example let s see how this new asynchronous version can now be consumed on an event handler from an UI button click event, and do this also in an asynchronous way using the TAP. // Asynchronous void method using TAP private async void sumbutton_click( RoutedEventArgs e) sumbutton.isenabled = false; await SumPageSizesAsync(GetUrls())); sumbutton.isenabled = true; For further analysis the synchronous version of a similar code is also presented, and as we will see the differences in execution will be bigger than the similarities of the code. 1 If context prevalence isn t required, the cost of context switching can be avoided. 2 In fact the method is called DownloadDataTaskAsync and is defined in the Visual Studio Async CTP [4] as an extension method for the WebClient, where it was implemented as a wrapper for TAP around the EAP implementation.

6 // Synchronous version provided for analysis private void sumbutton_click( RoutedEventArgs e) sumbutton.isenabled = false; SumPageSizes(GetUrls())); // Blocks the thread sumbutton.isenabled = true; If we start the analysis on the synchronous version, we notice that we can t call the asynchronous version of the SumPageSizes, so we have to use a synchronous version of the operation, which leads to the problem of the thread being blocked until the operation ends. As a consequence the expected behavior of disabling the button before the call and enabling it afterwards will never be noticed as the thread is blocked in the operation call. On the asynchronous method version, all these problems go away. In the first place, as the button handler is an asynchronous method we are allowed to await operations in it, so we can await the asynchronous version of the DownloadData using the DownloadDataAsync method. The expected behavior of disabling the button while we are downloading data, will now work as expected, as the thread will be freed on the await and the UI thread will be able to continue to process messages. Finally, once the download data completes, code execution will be resumed on the sumbutton.isenabled = true statement, and it will run on the UI context as expected. 5.2 Exception handling In terms of exception handling, TAP greatly simplifies the work that needs to be done. If an asynchronous method leaves an exception unhandled, it will be marshaled to the returning Task or Task<TResult> and will put the Task in a Faulted state. This rule is only broken when the exception is of type OperationCanceledException, raised due a cancelation request that has been processed by a cancelation token, in which case the Task will be ended in the Canceled state. So, handling exceptions for an asynchronous method is similar to handling exceptions for a synchronous one. Let s see how we can check for exceptions in our DownloadDataAsync method: private async void sumbutton_click( RoutedEventArgs e) sumbutton.isenabled = false; try await SumPageSizesAsync(GetUrls())); catch (Exception ex) // Handle the exception sumbutton.isenabled = true; As we can see, handling exceptions with the TAP it s as simple and natural as it can be. It s just the same as when we do synchronous code. All the hard work is now resolved by the language support along with the C# and Visual Basic compilers which together are able to bring simplicity for the TAP consumers. An approach to the TAP implementation details regarding the syntactic expansion that is done by the C# compiler can be found in [6]. 6. CONCLUSIONS APM and EAP patterns are clearly inappropriate for the current challenges, e.g., where the needs for asynchrony and parallelism are everywhere. A new and more simplified way of dealing with these requirements was needed to keep developers focused in the business logic instead dealing with technology artifacts. The Visual Studio Async CTP [4] as an early preview of what we can expect for the next version of C# and Visual Basic is the answer provided by Microsoft to accomplish this, and the vision behind it seems to be perfectly aligned with the current needs for asynchrony and parallelism as they appear in every day s developer lives. This paper briefly discussed what the Visual Studio Async CTP [4] is and which are the goals it tries to reach. A lot was left uncovered, for instance the built-in task Combinators: Run, WhenAll, WhenAny and Yield; the construction of Task-based Combinators and Task-based Data Structures; both have a key role on building larger patterns [5]. Many details were also absent from this article as they can be found in [2], [5] and [6]; the purpose of the article was mainly to expose the technology in conference literature. TPL Dataflow also introduced by the Visual Studio Async CTP [4] was not discussed in this paper and is meant to be covered in another article along with the benefits that it brings to the development of concurrent applications. Finally, asynchrony is not the same as parallelism, but TAP not only simplifies asynchrony, it also provides a vehicle for parallelism in a better and simplified way. Once developers start to adhere to this new pattern they will see how fast and simple it can be to implement operations that can easily be consumed in asynchronous and parallel environments. In fact, current operations that already expose tasks in their return values are possible candidates for this, and the next step would be the usage and implementation of asynchronous methods around those tasks. 7. REFERENCES [1] Syme, Don, Petricek, Tomas, and Lomov, Dmitry. The F# Asynchronous Programming Model. In Practical Aspects of Declarative Languages (PADL'11) (Austin, Texas, USA 2011). [2] Torgersen, Mads. Asynchrounous Programming in C# and Visual Basic. Microsoft Visual Studio Async CTP Documentation. [3] Hejlsberg, Anders. PDC10 - The Future of C# and Visual Basic. Microsoft af8e-ac747fee677a. [4] MICROSOFT. Visual Studio Async CTP [5] Toub, Stephen. The Task-based Asynchronous Pattern. Microsoft Visual Studio Async CTP Documentation. [6] MICROSOFT. Asynchronous Functions in C# Visual Studio Async CTP Documentation.

The Task-based Asynchronous Pattern

The Task-based Asynchronous Pattern The Task-based Asynchronous Pattern Stephen Toub, Microsoft February 2012 Contents Overview... 2 The Task-based Asynchronous Pattern Defined... 2 Naming, Parameters, and Return Types... 2 Behavior... 3

More information

Task-based Asynchronous Pattern 1 Implementing the Task-based Asynchronous Pattern 8 Interop with Other Asynchronous Patterns and Types 14

Task-based Asynchronous Pattern 1 Implementing the Task-based Asynchronous Pattern 8 Interop with Other Asynchronous Patterns and Types 14 Task-based Asynchronous Pattern 1 Implementing the Task-based Asynchronous Pattern 8 Interop with Other Asynchronous Patterns and Types 14 Task-based Asynchronous Pattern (TAP) https://msdn.microsoft.com/en-us/library/hh873175(d=printer,v=vs.110).aspx

More information

Asynchronous Functions in C#

Asynchronous Functions in C# Asynchronous Functions in C# Asynchronous operations are methods and other function members that may have most of their execution take place after they return. In.NET the recommended pattern for asynchronous

More information

Asynchronous Programming Demystified

Asynchronous Programming Demystified Asynchronous Programming Demystified http://submain.com/webcasts/asynchronous-programming-demystified/ for the webcast recording, slides and demo code download 1/14/2015 Webcast Housekeeping Audio Connect

More information

ASYNCHRONOUS PROGRAMMING IN C# 5 WITHOUT USE OF MULTIPLE THREADS

ASYNCHRONOUS PROGRAMMING IN C# 5 WITHOUT USE OF MULTIPLE THREADS ASYNCHRONOUS PROGRAMMING IN C# 5 WITHOUT USE OF MULTIPLE THREADS Aleš Keprt Department of Informatics, Moravian College Olomouc ales.keprt@mvso.cz ABSTRACT: Asynchrony is a situation when multiple things

More information

The Future of Parallel Programming in the.net Framework. Igor Ostrovsky Software Engineer Microsoft Corporation

The Future of Parallel Programming in the.net Framework. Igor Ostrovsky Software Engineer Microsoft Corporation The Future of Parallel Programming in the.net Framework Igor Ostrovsky Software Engineer Microsoft Corporation DISCLAIMER This is a talk about the near future All content is subject to change. The technology

More information

Concurrent Programming

Concurrent Programming Concurrent Programming Adam Przybyłek, 2016 przybylek.wzr.pl This work is licensed under a Creative Commons Attribution 4.0 International License. Task Parallel Library (TPL) scales the degree of concurrency

More information

An Async Primer. By Bill Wagner August Introduction

An Async Primer. By Bill Wagner August Introduction An Async Primer By Bill Wagner August 2012 Introduction The C# 5.0 release might seem small, given that the single major feature is the addition of async / await keywords to support asynchronous programming.

More information

Event-based Asynchronous Pattern Overview 1 Implementing the Event-based Asynchronous Pattern 5 Deciding When to Implement the Event-based

Event-based Asynchronous Pattern Overview 1 Implementing the Event-based Asynchronous Pattern 5 Deciding When to Implement the Event-based Event-based Asynchronous Pattern Overview 1 Implementing the Event-based Asynchronous Pattern 5 Deciding When to Implement the Event-based Asynchronous Pattern 12 Implementing Component with the Event-based

More information

VS08 This One Goes to Going Parallel with PFX, PLINQ, TPL and Async Keywords

VS08 This One Goes to Going Parallel with PFX, PLINQ, TPL and Async Keywords VS08 This One Goes to Going Parallel with PFX, PLINQ, TPL and Async Keywords Brian Noyes Chief Architect, IDesign Inc (www.idesign.net) brian.noyes@idesign.net, @briannoyes About Brian Chief Architect

More information

C# Asynchronous Programming Model

C# Asynchronous Programming Model Spring 2014 C# Asynchronous Programming Model A PRACTICAL GUIDE BY CHRIS TEDFORD TABLE OF CONTENTS Introduction... 2 Background Information... 2 Basic Example... 3 Specifications and Usage... 4 BeginInvoke()...

More information

Introduce C# as Object Oriented programming language. Explain, tokens,

Introduce C# as Object Oriented programming language. Explain, tokens, Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation

More information

MCSA Universal Windows Platform. A Success Guide to Prepare- Programming in C# edusum.com

MCSA Universal Windows Platform. A Success Guide to Prepare- Programming in C# edusum.com 70-483 MCSA Universal Windows Platform A Success Guide to Prepare- Programming in C# edusum.com Table of Contents Introduction to 70-483 Exam on Programming in C#... 2 Microsoft 70-483 Certification Details:...

More information

Asynchronous Programming with Async and Await 1 Await Operator 12 Async 15 Accessing the Web by Using Async and Await 18 Extend the Async Walkthrough

Asynchronous Programming with Async and Await 1 Await Operator 12 Async 15 Accessing the Web by Using Async and Await 18 Extend the Async Walkthrough Asynchronous Programming with Async and Await 1 Await Operator 12 Async 15 Accessing the Web by Using Async and Await 18 Extend the Async Walkthrough by Using Task.WhenAll 33 Make Multiple Web Requests

More information

Upcoming Features in C# Mads Torgersen, MSFT

Upcoming Features in C# Mads Torgersen, MSFT Upcoming Features in C# Mads Torgersen, MSFT This document describes language features currently planned for C# 6, the next version of C#. All of these are implemented and available in VS 2015 Preview.

More information

Implementation of F# language support in JetBrains Rider IDE

Implementation of F# language support in JetBrains Rider IDE SAINT-PETERSBURG STATE UNIVERSITY Software Engineering Evgeniy Auduchinok Implementation of F# language support in JetBrains Rider IDE Graduation Thesis Scientific supervisor: Senior lecturer Iakov Kirilenko

More information

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 10/e Copyright 1992-2015 by Pearson Education, Inc. All Rights Reserved. Data structures Collections of related data items. Discussed in depth in Chapters 16 21. Array objects Data

More information

Asynchronous Programming

Asynchronous Programming Asynchronous Programming Agenda Why async priogramming The Task abstraction Creating Tasks Passing data into tasks and retrieving results Cancellation Task dependency Task Scheduling 2 2 The Benefits of

More information

D Programming Language

D Programming Language Group 14 Muazam Ali Anil Ozdemir D Programming Language Introduction and Why D? It doesn t come with a religion this is written somewhere along the overview of D programming language. If you actually take

More information

Microsoft Visual C# Step by Step. John Sharp

Microsoft Visual C# Step by Step. John Sharp Microsoft Visual C# 2013 Step by Step John Sharp Introduction xix PART I INTRODUCING MICROSOFT VISUAL C# AND MICROSOFT VISUAL STUDIO 2013 Chapter 1 Welcome to C# 3 Beginning programming with the Visual

More information

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Introduction to Asynchronous Programming Fall 2014

Introduction to Asynchronous Programming Fall 2014 CS168 Computer Networks Fonseca Introduction to Asynchronous Programming Fall 2014 Contents 1 Introduction 1 2 The Models 1 3 The Motivation 3 4 Event-Driven Programming 4 5 select() to the rescue 5 1

More information

POINT OF FAILURES TOPICS .NET. msdn

POINT OF FAILURES TOPICS .NET. msdn 1 TOPICS POINT OF FAILURES msdn.net 2 THREADS TASKS msdn.net 3 KEY FEATURES msdn.net 4 TASK CREATION var task = new Task(Func func); task.start(); //... task.wait(); var task = Task.Run(Func

More information

Guidelines for Writing C Code

Guidelines for Writing C Code Guidelines for Writing C Code Issue 01-bugfix Martin Becker Institute for Real-Time Computer Systems (RCS) Technische Universität München becker@rcs.ei.tum.de June 9, 2014 Contents 1 Introduction 1 2 Pragmatic

More information

STARCOUNTER. Technical Overview

STARCOUNTER. Technical Overview STARCOUNTER Technical Overview Summary 3 Introduction 4 Scope 5 Audience 5 Prerequisite Knowledge 5 Virtual Machine Database Management System 6 Weaver 7 Shared Memory 8 Atomicity 8 Consistency 9 Isolation

More information

Microprofile Fault Tolerance. Emily Jiang 1.0,

Microprofile Fault Tolerance. Emily Jiang 1.0, Microprofile Fault Tolerance Emily Jiang 1.0, 2017-09-13 Table of Contents 1. Architecture.............................................................................. 2 1.1. Rational..............................................................................

More information

PROCESSES AND THREADS THREADING MODELS. CS124 Operating Systems Winter , Lecture 8

PROCESSES AND THREADS THREADING MODELS. CS124 Operating Systems Winter , Lecture 8 PROCESSES AND THREADS THREADING MODELS CS124 Operating Systems Winter 2016-2017, Lecture 8 2 Processes and Threads As previously described, processes have one sequential thread of execution Increasingly,

More information

Sri Lanka Institute of Information Technology System Programming and Design II Year 3 Tutorial 06

Sri Lanka Institute of Information Technology System Programming and Design II Year 3 Tutorial 06 Sri Lanka Institute of Information Technology System Programming and Design II Year 3 Tutorial 06 1. What is an asynchronous call? How does it differ from a synchronous call? In synchronous call, the caller

More information

Grand Central Dispatch and NSOperation. CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015

Grand Central Dispatch and NSOperation. CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015 Grand Central Dispatch and NSOperation CSCI 5828: Foundations of Software Engineering Lecture 28 12/03/2015 1 Credit Where Credit Is Due Most of the examples in this lecture were inspired by example code

More information

The Various Faces of the.net Task Parallel Library

The Various Faces of the.net Task Parallel Library The Various Faces of the.net Task Parallel Library Luc Bläser Hochschule für Technik Rapperswil Multicore@Siemens 2015 5 Feb 2015, Nuremberg The.NET Task Parallel Library (TPL) State of the art in.net

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE

More information

COMIC BOOK GRAPHIC NOVEL APPROACH TO ASYNC

COMIC BOOK GRAPHIC NOVEL APPROACH TO ASYNC KATHLEEN DOLLARD - CODERAPID @KATHLEENDOLLARD KATHLEENDOLLARD KATHLEEN@MVPS.ORG BLOG: HTTP://BLOGS.MSMVPS.COM/KATHLEEN HT TP://WWW.PLURALSIGHT.COM/AUTHOR/KATHLEEN - DOLLARD Puzzles Workshop Puzzles EXPLORING

More information

An Overview of the BLITZ System

An Overview of the BLITZ System An Overview of the BLITZ System Harry H. Porter III Department of Computer Science Portland State University Introduction The BLITZ System is a collection of software designed to support a university-level

More information

Asynchronous Programming Model (APM) 1 Calling Asynchronous Methods Using IAsyncResult 4 Blocking Application Execution by Ending an Async Operation

Asynchronous Programming Model (APM) 1 Calling Asynchronous Methods Using IAsyncResult 4 Blocking Application Execution by Ending an Async Operation Asynchronous Programming Model (APM) 1 Calling Asynchronous Methods Using IAsyncResult 4 Blocking Application Execution by Ending an Async Operation 5 Blocking Application Execution Using an AsyncWaitHandle

More information

Object Oriented Programming with Java. Unit-1

Object Oriented Programming with Java. Unit-1 CEB430 Object Oriented Programming with Java Unit-1 PART A 1. Define Object Oriented Programming. 2. Define Objects. 3. What are the features of Object oriented programming. 4. Define Encapsulation and

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

Patterns for Asynchronous Invocations in Distributed Object Frameworks

Patterns for Asynchronous Invocations in Distributed Object Frameworks Patterns for Asynchronous Invocations in Distributed Object Frameworks Patterns for Asynchronous Invocations in Distributed Object Frameworks Markus Voelter Michael Kircher Siemens AG, Corporate Technology,

More information

C#: framework overview and in-the-small features

C#: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer C#: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

CS 160: Interactive Programming

CS 160: Interactive Programming CS 160: Interactive Programming Professor John Canny 3/8/2006 1 Outline Callbacks and Delegates Multi-threaded programming Model-view controller 3/8/2006 2 Callbacks Your code Myclass data method1 method2

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

Software Development & Education Center. Java Platform, Standard Edition 7 (JSE 7)

Software Development & Education Center. Java Platform, Standard Edition 7 (JSE 7) Software Development & Education Center Java Platform, Standard Edition 7 (JSE 7) Detailed Curriculum Getting Started What Is the Java Technology? Primary Goals of the Java Technology The Java Virtual

More information

UriQuery query.add + query.tostring()

UriQuery query.add + query.tostring() Employee employee = Employees.CurrentItem as Employee; if (employee!= null) UriQuery query = new UriQuery(); query.add("id", employee.id); _regionmanager.requestnavigate(regionnames.tabregion, new Uri("EmployeeDetailsView"

More information

Software Exception Flow Analysis for WPF C# Asynchronous Programs Using Microsoft Visual Studio

Software Exception Flow Analysis for WPF C# Asynchronous Programs Using Microsoft Visual Studio Software Exception Flow Analysis for WPF C# Asynchronous Programs Using Microsoft Visual Studio Summary Recently, I was working on an implementation of a new software product feature based on asynchronous

More information

CPSC 427a: Object-Oriented Programming

CPSC 427a: Object-Oriented Programming CPSC 427a: Object-Oriented Programming Michael J. Fischer Lecture 5 September 15, 2011 CPSC 427a, Lecture 5 1/35 Functions and Methods Parameters Choosing Parameter Types The Implicit Argument Simple Variables

More information

Course Hours

Course Hours Programming the.net Framework 4.0/4.5 with C# 5.0 Course 70240 40 Hours Microsoft's.NET Framework presents developers with unprecedented opportunities. From 'geoscalable' web applications to desktop and

More information

Communication. Distributed Systems Santa Clara University 2016

Communication. Distributed Systems Santa Clara University 2016 Communication Distributed Systems Santa Clara University 2016 Protocol Stack Each layer has its own protocol Can make changes at one layer without changing layers above or below Use well defined interfaces

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object

More information

Java Threads and intrinsic locks

Java Threads and intrinsic locks Java Threads and intrinsic locks 1. Java and OOP background fundamentals 1.1. Objects, methods and data One significant advantage of OOP (object oriented programming) is data encapsulation. Each object

More information

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections Thread Safety Today o Confinement o Threadsafe datatypes Required reading Concurrency Wrapper Collections Optional reading The material in this lecture and the next lecture is inspired by an excellent

More information

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions CSE1720 Click to edit Master Week text 01, styles Lecture 02 Second level Third level Fourth level Fifth level Winter 2015! Thursday, Jan 8, 2015 1 Objectives for this class meeting 1. Conduct review of

More information

public class Foo { private int var; public int Method1() { // var accessible anywhere here } public int MethodN() {

public class Foo { private int var; public int Method1() { // var accessible anywhere here } public int MethodN() { Scoping, Static Variables, Overloading, Packages In this lecture, we will examine in more detail the notion of scope for variables. We ve already indicated that variables only exist within the block they

More information

Overview of the Ruby Language. By Ron Haley

Overview of the Ruby Language. By Ron Haley Overview of the Ruby Language By Ron Haley Outline Ruby About Ruby Installation Basics Ruby Conventions Arrays and Hashes Symbols Control Structures Regular Expressions Class vs. Module Blocks, Procs,

More information

Introducing C# and the.net Framework

Introducing C# and the.net Framework 1 Introducing C# and the.net Framework C# is a general-purpose, type-safe, object-oriented programming language. The goal of the language is programmer productivity. To this end, the language balances

More information

Professional ASP.NET Web Services : Asynchronous Programming

Professional ASP.NET Web Services : Asynchronous Programming Professional ASP.NET Web Services : Asynchronous Programming To wait or not to wait; that is the question! Whether or not to implement asynchronous processing is one of the fundamental issues that a developer

More information

In the CERTAINTY project, an application is defined as a network of independent processes with the following features:

In the CERTAINTY project, an application is defined as a network of independent processes with the following features: C/C++ Coding Guide G. Giannopoulou, P. Huang, N. Stoimenov, L. Thiele April 15, 2014 This document describes how to program DOL-Critical applications using C/C++ as programming language. To be able to

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming

Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming Written Presentation: JoCaml, a Language for Concurrent Distributed and Mobile Programming Nicolas Bettenburg 1 Universitaet des Saarlandes, D-66041 Saarbruecken, nicbet@studcs.uni-sb.de Abstract. As traditional

More information

Object Oriented Programming Exception Handling

Object Oriented Programming Exception Handling Object Oriented Programming Exception Handling Budditha Hettige Department of Computer Science Programming Errors Types Syntax Errors Logical Errors Runtime Errors Syntax Errors Error in the syntax of

More information

Chapter 4: Multi-Threaded Programming

Chapter 4: Multi-Threaded Programming Chapter 4: Multi-Threaded Programming Chapter 4: Threads 4.1 Overview 4.2 Multicore Programming 4.3 Multithreading Models 4.4 Thread Libraries Pthreads Win32 Threads Java Threads 4.5 Implicit Threading

More information

Asynchronous OSGi: Promises for the masses. Tim Ward.

Asynchronous OSGi: Promises for the masses. Tim Ward. Asynchronous OSGi: Promises for the masses Tim Ward http://www.paremus.com info@paremus.com Who is Tim Ward? @TimothyWard Senior Consulting Engineer, Trainer and Architect at Paremus 5 years at IBM developing

More information

Lecture 2: Architectural Support for OSes

Lecture 2: Architectural Support for OSes Lecture 2: Architectural Support for OSes CSE 120: Principles of Operating Systems Alex C. Snoeren HW 1 Due Tuesday 10/03 Why Architecture? Operating systems mediate between applications and the physical

More information

Parallelizing Ocean plug-in computations using the Background Worker + PFX pattern

Parallelizing Ocean plug-in computations using the Background Worker + PFX pattern Parallelizing Ocean plug-in computations using the Background Worker + PFX pattern Dmitriy Repin Program Architect, Schlumberger PTS Ocean Development Framework User Meeting Houston, October 24, 2014 2014

More information

Grand Central Dispatch

Grand Central Dispatch A better way to do multicore. (GCD) is a revolutionary approach to multicore computing. Woven throughout the fabric of Mac OS X version 10.6 Snow Leopard, GCD combines an easy-to-use programming model

More information

Project Compiler. CS031 TA Help Session November 28, 2011

Project Compiler. CS031 TA Help Session November 28, 2011 Project Compiler CS031 TA Help Session November 28, 2011 Motivation Generally, it s easier to program in higher-level languages than in assembly. Our goal is to automate the conversion from a higher-level

More information

BEAAquaLogic. Service Bus. Interoperability With EJB Transport

BEAAquaLogic. Service Bus. Interoperability With EJB Transport BEAAquaLogic Service Bus Interoperability With EJB Transport Version 3.0 Revised: February 2008 Contents EJB Transport Introduction...........................................................1-1 Invoking

More information

Previous C# Releases. C# 3.0 Language Features. C# 3.0 Features. C# 3.0 Orcas. Local Variables. Language Integrated Query 3/23/2007

Previous C# Releases. C# 3.0 Language Features. C# 3.0 Features. C# 3.0 Orcas. Local Variables. Language Integrated Query 3/23/2007 Previous C# Releases C# 3.0 Language Features C# Programming March 12, 2007 1.0 2001 1.1 2003 2.0 2005 Generics Anonymous methods Iterators with yield Static classes Covariance and contravariance for delegate

More information

Exception-Handling Overview

Exception-Handling Overview م.عبد الغني أبوجبل Exception Handling No matter how good a programmer you are, you cannot control everything. Things can go wrong. Very wrong. When you write a risky method, you need code to handle the

More information

Decaf Language Reference Manual

Decaf Language Reference Manual Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented

More information

Stating the obvious, people and computers do not speak the same language.

Stating the obvious, people and computers do not speak the same language. 3.4 SYSTEM SOFTWARE 3.4.3 TRANSLATION SOFTWARE INTRODUCTION Stating the obvious, people and computers do not speak the same language. People have to write programs in order to instruct a computer what

More information

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including: Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including: Abstraction Encapsulation Inheritance and Polymorphism Object-Oriented

More information

CSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige

CSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige CSC 308 2.0 System Development with Java Exception Handling Department of Statistics and Computer Science 1 2 Errors Errors can be categorized as several ways; Syntax Errors Logical Errors Runtime Errors

More information

Outline. Threads. Single and Multithreaded Processes. Benefits of Threads. Eike Ritter 1. Modified: October 16, 2012

Outline. Threads. Single and Multithreaded Processes. Benefits of Threads. Eike Ritter 1. Modified: October 16, 2012 Eike Ritter 1 Modified: October 16, 2012 Lecture 8: Operating Systems with C/C++ School of Computer Science, University of Birmingham, UK 1 Based on material by Matt Smart and Nick Blundell Outline 1 Concurrent

More information

CSE 70 Final Exam Fall 2009

CSE 70 Final Exam Fall 2009 Signature cs70f Name Student ID CSE 70 Final Exam Fall 2009 Page 1 (10 points) Page 2 (16 points) Page 3 (22 points) Page 4 (13 points) Page 5 (15 points) Page 6 (20 points) Page 7 (9 points) Page 8 (15

More information

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26

COSC 2P95. Procedural Abstraction. Week 3. Brock University. Brock University (Week 3) Procedural Abstraction 1 / 26 COSC 2P95 Procedural Abstraction Week 3 Brock University Brock University (Week 3) Procedural Abstraction 1 / 26 Procedural Abstraction We ve already discussed how to arrange complex sets of actions (e.g.

More information

Implementing Continuations

Implementing Continuations Implementing Continuations sk and dbtucker 2002-10-18 1 Changing Representations Now that we ve seen how continuations work, let s study how to implement them in an interpreter. For this lecture onward,

More information

Chapter 4: Threads. Operating System Concepts 9 th Edition

Chapter 4: Threads. Operating System Concepts 9 th Edition Chapter 4: Threads Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues Operating System Examples

More information

NODE.JS MOCK TEST NODE.JS MOCK TEST I

NODE.JS MOCK TEST NODE.JS MOCK TEST I http://www.tutorialspoint.com NODE.JS MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Node.js Framework. You can download these sample mock tests at

More information

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications Distributed Objects and Remote Invocation Programming Models for Distributed Applications Extending Conventional Techniques The remote procedure call model is an extension of the conventional procedure

More information

Lecture Notes on Memory Layout

Lecture Notes on Memory Layout Lecture Notes on Memory Layout 15-122: Principles of Imperative Computation Frank Pfenning André Platzer Lecture 11 1 Introduction In order to understand how programs work, we can consider the functions,

More information

Kakadu and Java. David Taubman, UNSW June 3, 2003

Kakadu and Java. David Taubman, UNSW June 3, 2003 Kakadu and Java David Taubman, UNSW June 3, 2003 1 Brief Summary The Kakadu software framework is implemented in C++ using a fairly rigorous object oriented design strategy. All classes which are intended

More information

Chapter 4: Threads. Operating System Concepts 9 th Edition

Chapter 4: Threads. Operating System Concepts 9 th Edition Chapter 4: Threads Silberschatz, Galvin and Gagne 2013 Chapter 4: Threads Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues Operating System Examples

More information

Justification for Names and Optional Parameters

Justification for Names and Optional Parameters Justification for Names and Optional Parameters By Bill Wagner March 2012 Many developers ask why named and optional parameters were not added earlier to the C# language. As other languages have shown,

More information

Threads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits

Threads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits CS307 What is a thread? Threads A thread is a basic unit of CPU utilization contains a thread ID, a program counter, a register set, and a stack shares with other threads belonging to the same process

More information

CS61B, Spring 2003 Discussion #17 Amir Kamil UC Berkeley 5/12/03

CS61B, Spring 2003 Discussion #17 Amir Kamil UC Berkeley 5/12/03 CS61B, Spring 2003 Discussion #17 Amir Kamil UC Berkeley 5/12/03 Topics: Threading, Synchronization 1 Threading Suppose we want to create an automated program that hacks into a server. Many encryption

More information

Java. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)

Java. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2) Summary: Chapters 1 to 10 Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX 76019 Email: sharma@cse.uta.edu

More information

Multithreading and Interactive Programs

Multithreading and Interactive Programs Multithreading and Interactive Programs CS160: User Interfaces John Canny. This time Multithreading for interactivity need and risks Some design patterns for multithreaded programs Debugging multithreaded

More information

Multithreading and Interactive Programs

Multithreading and Interactive Programs Multithreading and Interactive Programs CS160: User Interfaces John Canny. Last time Model-View-Controller Break up a component into Model of the data supporting the App View determining the look of the

More information

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going

More information

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism Block 1: Introduction to Java Unit 4: Inheritance, Composition and Polymorphism Aims of the unit: Study and use the Java mechanisms that support reuse, in particular, inheritance and composition; Analyze

More information

15CS45 : OBJECT ORIENTED CONCEPTS

15CS45 : OBJECT ORIENTED CONCEPTS 15CS45 : OBJECT ORIENTED CONCEPTS QUESTION BANK: What do you know about Java? What are the supported platforms by Java Programming Language? List any five features of Java? Why is Java Architectural Neutral?

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 18 Thursday, March 29, 2018 In abstract algebra, algebraic structures are defined by a set of elements and operations

More information

SERG. A Study and Toolkit for Asynchronous Programming in C#

SERG. A Study and Toolkit for Asynchronous Programming in C# Delft University of Technology Software Engineering Research Group Technical Report Series A Study and Toolkit for Asynchronous Programming in C# Semih Okur, David L. Hartveld, Danny Dig and Arie van Deursen

More information

Compaq Interview Questions And Answers

Compaq Interview Questions And Answers Part A: Q1. What are the difference between java and C++? Java adopts byte code whereas C++ does not C++ supports destructor whereas java does not support. Multiple inheritance possible in C++ but not

More information

Lecture 15: Network File Systems

Lecture 15: Network File Systems Lab 3 due 12/1 Lecture 15: Network File Systems CSE 120: Principles of Operating Systems Alex C. Snoeren Network File System Simple idea: access disks attached to other computers Share the disk with many

More information

A Standard Programmatic Interface for Asynchronous Operations

A Standard Programmatic Interface for Asynchronous Operations Doc No: N3327=12-0017 Date: 2012-01-12 Project: JTC1.22.32 Reply to: Niklas Gustafsson Artur Laksberg Microsoft Corp. 1 Microsoft Way Redmond WA USA 98052-6399 Fax: +1-928-438-4456 Email: niklas.gustafsson@microsoft.com

More information

JS Event Loop, Promises, Async Await etc. Slava Kim

JS Event Loop, Promises, Async Await etc. Slava Kim JS Event Loop, Promises, Async Await etc Slava Kim Synchronous Happens consecutively, one after another Asynchronous Happens later at some point in time Parallelism vs Concurrency What are those????

More information

Microsoft. Microsoft Visual C# Step by Step. John Sharp

Microsoft. Microsoft Visual C# Step by Step. John Sharp Microsoft Microsoft Visual C#- 2010 Step by Step John Sharp Table of Contents Acknowledgments Introduction xvii xix Part I Introducing Microsoft Visual C# and Microsoft Visual Studio 2010 1 Welcome to

More information