1. Trang chủ
  2. » Giáo Dục - Đào Tạo

213 chapter 09 tủ tài liệu training

59 77 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 59
Dung lượng 23,16 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Introduction to LINQLINQ stands for L anguage- In tegrated Q uery, it is a query syntax used to bridges the gap between the world of objects and the world of data.. LINQ to Objects LIN

Trang 7

Introduction to LINQ

LINQ stands for L anguage- In tegrated Q uery,  it is a query syntax used to bridges the

gap between the world of objects and the world of data.

LINQ to Objects LINQ to DataSet LINQ to XML LINQ to Entities

LINQ to SQL

Method Syntax Query Syntax

Trang 9

Introduction to LINQ

Familiar language : you don’t have to learn a new query language for each type of data source or data format.

Less coding : It reduces the amount of code comparing to the normal approach.

Readable code : LINQ makes the code more readable

Standardization : The same LINQ syntax can be used to query multiple data sources.

Trang 12

LINQ - method syntax exercise

Salary about higher than 4000 and last appraisal less than 8

Use the DisplayWithAppraisal method

Trang 15

LINQ - query syntax exercise

Salary about higher than 4000 and last appraisal less than 8

Use the DisplayWithAppraisal method

Trang 21

keystrokes Checking Syntax Displaying Intellisense Offering Solutions for errors

Trang 22

Introduction to multithreading

Advantages of multithreading

Responsiveness: multithreading allow an application to remain responsive.

Faster execution: multithreaded applications operate faster on computers that have multiple CPUs.

Lower resource consumption: multithreaded applications can handle multiple requests simultaneously using fewer resources Better system utilization : multithreaded applications can be doing different tasks at the same time not in a sequential order.

Disadvantages of multithreading

Complexity: Increases the complexity of your application

Difficulty to write code: because you are place each task on a separate independent thread

Difficulty to debug code: because the application will not work in a sequential way anymore

Difficulty to test code: for the same previous two reasons

Potential deadlocks : when two or more threads are blocking each other.

Trang 23

Introduction to multithreading

Critical Section

is a section of code that needs to be executed without being interpreted.

For example

• A user trying to reserve the last ticket available on a plane

• One thread is opening a file and another thread is writing in the file

Trang 31

Deadlocks and lock keyword

Deadlock occurs when a thread enters a waiting state because a requested system resource is held by another waiting thread, which in turn is waiting for another resource held by another waiting threat.

Trang 32

Deadlocks and lock keyword

Lock keyword will ensure that one thread is executing a piece of code at one time Which means

that one thread does not enter a critical section of code while another thread is in that critical

section.

Trang 37

Limits the number of threads that can access a resource or pool of resources concurrently.

Trang 39

Introduction to asynchronous programming

Trang 40

Introduction to asynchronous programming

Synchronous Programming 

Single Threaded Multi-Threaded

Trang 41

Introduction to asynchronous programming

Asynchronous Programming 

Single Threaded Multi-Threaded

Thread 1

executing another tasks.

Thread 1

Thread 2

Thread 3

Task 2 Task 4

Trang 42

Synchronous model means two or more tasks are running at the same time and it is possible

that one may block another

Asynchronous model means two or more operations are running in different contexts (thread)

so that they can run concurrently and do not block each other.

Trang 44

Task represents an asynchronous operation.

Trang 56

Assignment No.19: (Search in a list using LINQ)

• Display count of search result

• Add numbers before each line

• Add a parameter in the display method to display the title or not

Trang 57

Assignment No.20: (Say hi in 7 different languages)

• Create a list of threads

• Create a class called Hi contains 7 or so different SayHi methods in different languages

• Each SayHi method has a name and a count to display how many times

Trang 58

Assignment No.21: (Fastest task)

• Creating two tasks whatever task finishes first cancels the other one and display the maximum value the cancelled one reaches

Trang 59

Assignment No.22: (ConcurrentStack)

• Create concurrent stack and fill it with integers using two different threads

• Access it using two different threads

• Count how many items each thread accessed

Ngày đăng: 16/11/2019, 23:18

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN