Creating a Simple PLINQ Query
PLINQ-Parallel LINQ:-It is the parallel implementation of LINQ, in which a query can be executed by using multiple processors.
A simple PLIQ query works on a large collection of data. This implies that on a small collection of data, the effect of a PLINQ is not visible.
Now, we add the Default.aspx page and write the following code:
Now, double click on Display Record button and write the following code:-
Now run the application and click on Display Record button and get output.
A simple PLIQ query works on a large collection of data. This implies that on a small collection of data, the effect of a PLINQ is not visible.
Now, we add the Default.aspx page and write the following code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
Now, double click on Display Record button and write the following code:-
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnDisplayRecord_Click(object sender, EventArgs e) { lbDetail.Items.Clear(); int firstno, secondno, rangeno; firstno = Convert.ToInt32(txtFirstNo.Text); secondno = Convert.ToInt32(txtSecondNo.Text); rangeno = Convert.ToInt32(txtRangeNo.Text); var sourcedata = Enumerable.Range(firstno, secondno); var parallelQuery = from num in sourcedata.AsParallel().AsOrdered() where num % num == 0 select num; foreach (var data in parallelQuery) { if (data < secondno) { lbDetail.Items.Add(data.ToString()); } } } }
Now run the application and click on Display Record button and get output.