Click here to Skip to main content
16,019,140 members
Home / Discussions / C#
   

C#

 
GeneralRe: apple push notification Pin
Pete O'Hanlon5-Mar-18 20:54
mvePete O'Hanlon5-Mar-18 20:54 
GeneralRe: apple push notification Pin
Member 108437285-Mar-18 21:11
Member 108437285-Mar-18 21:11 
GeneralRe: apple push notification Pin
Gerry Schmitz6-Mar-18 5:58
mveGerry Schmitz6-Mar-18 5:58 
QuestionTaskFactory Class Pin
Member 137105305-Mar-18 16:37
Member 137105305-Mar-18 16:37 
AnswerRe: TaskFactory Class Pin
Pete O'Hanlon5-Mar-18 20:20
mvePete O'Hanlon5-Mar-18 20:20 
GeneralRe: TaskFactory Class Pin
Member 137105307-Mar-18 6:13
Member 137105307-Mar-18 6:13 
AnswerRe: TaskFactory Class Pin
Gerry Schmitz7-Mar-18 7:40
mveGerry Schmitz7-Mar-18 7:40 
GeneralRe: TaskFactory Class Pin
Member 1371053019-Mar-18 18:00
Member 1371053019-Mar-18 18:00 
Can anyone help with this? This code is working using Parallel.ForEach - I understand since I am doing I/O, I should be using Async/Await but need some help to incorporate this for my piece of code. I will comment about how/why/what I am doing below within my code. Thanks

// Piece of code to find out if a particular device has a specified piece of software entitled. Will have up to 10 devices in the grid.
// Someone has told me I am not using the Grid in the correct way, so I will eventually change the grid to a table.
if (dataGridView1.Rows.Count > 1)
{
string service = comboBox1.Text;
// Is it best to use a list or IEnumerable here? If IEnumerable, please help!
// populating internal url with device id from the grid, accessing same page,
// with different search parameter for each url
var urls = new List<string> { };
for (int index1 = 0; index1 < dataGridView1.Rows.Count - 1; index1++)
{
string gridDevice = dataGridView1.Rows[index1].Cells[0].Value.ToString();
urls.Add("http://<internal webite>.asp?type=search&OU=" + service + "<internal>&devicename=" + gridDevice + <internal>");
}

// Not sure how to use async/await - or any other suggestions and help would be appreciated.
Parallel.ForEach(urls, (url, state, index) =>
{
using (var client = new WebClient())
{
client.UseDefaultCredentials = true;
var contents = client.DownloadString(url);
// When I put Stopwatch ending here, I am seeing 1st time around 2 seconds, then increasing thru next 9 up to around 5 seconds.
// Total time I see to populate all 10 rows is around 15 seconds. Is it possible to get all 10 rows populated in approximately 3 seconds.
int vOut;
Match mTitle = Regex.Match(contents, ">" + service + "(.*?)<");
if (mTitle.Success)
{
string package = mTitle.Groups[0].Value;
string[] package1 = package.Split('>', '<');
vOut = Convert.ToInt32(index);
dataGridView1.Rows[vOut].Cells[5].Value = package1[1];
}
else
{
vOut = Convert.ToInt32(index);
dataGridView1.Rows[vOut].Cells[5].Value = "N/A";
}
}
});
}

c#
Questionc# parsing CAN dbc files Pin
Member 135713645-Mar-18 4:05
Member 135713645-Mar-18 4:05 
AnswerRe: c# parsing CAN dbc files Pin
Maciej Los5-Mar-18 20:27
mveMaciej Los5-Mar-18 20:27 
GeneralRe: c# parsing CAN dbc files Pin
Member 135713645-Mar-18 20:34
Member 135713645-Mar-18 20:34 
Questiontextbox input Pin
User 136751143-Mar-18 13:01
User 136751143-Mar-18 13:01 
AnswerRe: textbox input Pin
BillWoodruff3-Mar-18 14:31
professionalBillWoodruff3-Mar-18 14:31 
GeneralRe: textbox input Pin
User 136751143-Mar-18 23:56
User 136751143-Mar-18 23:56 
GeneralRe: textbox input PinPopular
OriginalGriff4-Mar-18 1:21
mveOriginalGriff4-Mar-18 1:21 
GeneralRe: textbox input Pin
BillWoodruff4-Mar-18 2:18
professionalBillWoodruff4-Mar-18 2:18 
GeneralRe: textbox input Pin
Luc Pattyn4-Mar-18 7:19
sitebuilderLuc Pattyn4-Mar-18 7:19 
GeneralRe: textbox input Pin
OriginalGriff4-Mar-18 19:27
mveOriginalGriff4-Mar-18 19:27 
GeneralRe: textbox input Pin
Pete O'Hanlon4-Mar-18 20:56
mvePete O'Hanlon4-Mar-18 20:56 
GeneralRe: textbox input Pin
OriginalGriff4-Mar-18 21:04
mveOriginalGriff4-Mar-18 21:04 
GeneralRe: textbox input Pin
Pete O'Hanlon4-Mar-18 21:10
mvePete O'Hanlon4-Mar-18 21:10 
QuestionHow to create a recursive lambda function ? Pin
Jesus Carroll2-Mar-18 12:26
professionalJesus Carroll2-Mar-18 12:26 
AnswerRe: How to create a recursive lambda function ? Pin
Eddy Vluggen2-Mar-18 12:32
professionalEddy Vluggen2-Mar-18 12:32 
PraiseRe: How to create a recursive lambda function ? Pin
Jesus Carroll2-Mar-18 12:48
professionalJesus Carroll2-Mar-18 12:48 
GeneralRe: How to create a recursive lambda function ? Pin
Eddy Vluggen2-Mar-18 13:05
professionalEddy Vluggen2-Mar-18 13:05 

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.