Click here to Skip to main content
15,117,549 members
Home / Discussions / C#
   

C#

 
GeneralRe: Authentication Error while migration of .net web application from VS2012 (.net 4.0) to VS2019 (.net 4.7.2)project Pin
Rohith PH16-Jun-20 2:31
MemberRohith PH16-Jun-20 2:31 
GeneralRe: Authentication Error while migration of .net web application from VS2012 (.net 4.0) to VS2019 (.net 4.7.2)project Pin
Richard Deeming16-Jun-20 3:29
mveRichard Deeming16-Jun-20 3:29 
GeneralRe: Authentication Error while migration of .net web application from VS2012 (.net 4.0) to VS2019 (.net 4.7.2)project Pin
Rohith PH17-Jun-20 0:40
MemberRohith PH17-Jun-20 0:40 
GeneralRe: Authentication Error while migration of .net web application from VS2012 (.net 4.0) to VS2019 (.net 4.7.2)project Pin
Richard Deeming17-Jun-20 0:49
mveRichard Deeming17-Jun-20 0:49 
QuestionProblem with serial port Pin
DanTheBest14-Jun-20 6:48
MemberDanTheBest14-Jun-20 6:48 
AnswerRe: Problem with serial port Pin
OriginalGriff14-Jun-20 9:27
mveOriginalGriff14-Jun-20 9:27 
QuestionHow To Write And Comsume An Async Method Pin
Kevin Marois12-Jun-20 7:47
professionalKevin Marois12-Jun-20 7:47 
AnswerRe: How To Write And Comsume An Async Method Pin
Richard Deeming12-Jun-20 9:09
mveRichard Deeming12-Jun-20 9:09 
I'm not convinced by that Task.Factory.StartNew call.

First of all, you should really be using Task.Run instead:
Task.Run vs Task.Factory.StartNew | .NET Parallel Programming[^]

But unless that code is CPU-bound, you've not really gained much. Most data access code is going to be IO-bound, so it should be using the async version of whatever methods you're using to load the data.

For example, if you're using a SqlCommand to load the data:
SqlConnection.OpenAsync(CancellationToken) Method (System.Data.SqlClient) | Microsoft Docs[^]
SqlCommand.ExecuteReaderAsync Method (System.Data.SqlClient) | Microsoft Docs[^]
SqlDataReader.ReadAsync(CancellationToken) Method (System.Data.SqlClient) | Microsoft Docs[^]
C#
public async Task<List<ReportData>> GetReportData(ReportArgsEntity args)
{
    // Make sure we're not blocking the UI thread:
    await Task.Yield().ConfigureAwait(false);
    
    using (var connection = new SqlConnection("..."))
    using (var command = new SqlCommand("...", connection))
    {
       await connection.OpenAsync();
       
       using (var reader = await command.ExecuteReaderAsync(CommandBehavior.CloseConnection))
       {
           var results = new List<ReportData>();
           
           while (await reader.ReadAsync())
           {
               ...
           }
           
           return results;
       }
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: How To Write And Comsume An Async Method Pin
Kevin Marois12-Jun-20 10:54
professionalKevin Marois12-Jun-20 10:54 
GeneralRe: How To Write And Comsume An Async Method Pin
Richard Deeming15-Jun-20 0:44
mveRichard Deeming15-Jun-20 0:44 
GeneralRe: How To Write And Comsume An Async Method Pin
Kevin Marois15-Jun-20 8:31
professionalKevin Marois15-Jun-20 8:31 
GeneralRe: How To Write And Comsume An Async Method Pin
Richard Deeming15-Jun-20 8:38
mveRichard Deeming15-Jun-20 8:38 
GeneralRe: How To Write And Comsume An Async Method Pin
Kevin Marois15-Jun-20 8:41
professionalKevin Marois15-Jun-20 8:41 
GeneralRe: How To Write And Comsume An Async Method Pin
Richard Deeming15-Jun-20 8:50
mveRichard Deeming15-Jun-20 8:50 
GeneralRe: How To Write And Comsume An Async Method Pin
Kevin Marois15-Jun-20 10:01
professionalKevin Marois15-Jun-20 10:01 
QuestionRemoving a field from jSon String Pin
simpledeveloper11-Jun-20 9:00
Membersimpledeveloper11-Jun-20 9:00 
AnswerRe: Removing a field from jSon String Pin
OriginalGriff11-Jun-20 23:44
mveOriginalGriff11-Jun-20 23:44 
GeneralRe: Removing a field from jSon String Pin
simpledeveloper12-Jun-20 10:05
Membersimpledeveloper12-Jun-20 10:05 
GeneralRe: Removing a field from jSon String Pin
OriginalGriff12-Jun-20 10:06
mveOriginalGriff12-Jun-20 10:06 
AnswerRe: Removing a field from jSon String Pin
James Curran17-Jun-20 21:23
MemberJames Curran17-Jun-20 21:23 
QuestionIs there any good C# desktop library to implement Card liked UI dashboard? Pin
yccheok11-Jun-20 7:31
Memberyccheok11-Jun-20 7:31 
AnswerRe: Is there any good C# desktop library to implement Card liked UI dashboard? Pin
Richard MacCutchan11-Jun-20 22:36
mveRichard MacCutchan11-Jun-20 22:36 
GeneralRe: Is there any good C# desktop library to implement Card liked UI dashboard? Pin
yccheok12-Jun-20 7:13
Memberyccheok12-Jun-20 7:13 
GeneralRe: Is there any good C# desktop library to implement Card liked UI dashboard? Pin
Richard MacCutchan12-Jun-20 7:43
mveRichard MacCutchan12-Jun-20 7:43 
QuestionHow to handle excel - multiple sheets integration with ODBC Driver connection in C# Pin
Member 1485915110-Jun-20 4:10
MemberMember 1485915110-Jun-20 4:10 

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.