Questions tagged [sendasync]

83 questions
18
votes
2 answers

What benefits can I take from SmtpClient.SendAsync's userToken object?

I was using SMTPClient.Send(mail) method to send emails, but then I saw, if the email id is not present (does not exists), my application waits till it receives the exception and then allows user to perform further tasks. So I thought of using…
Nagaraj Tantri
  • 5,172
  • 12
  • 54
  • 78
11
votes
2 answers

Dispose SmtpClient in SendComplete?

When I use SmtpClient's SendAsync to send email, how do I dispose the smtpclient instance correctly? Let's say: MailMessage mail = new System.Net.Mail.MailMessage() { Body = MailBody.ToString(), IsBodyHtml = true, From = new…
Jeff Chen
  • 736
  • 1
  • 8
  • 20
8
votes
1 answer

SmtpClient.SendAsync - How to stop the application exiting before the callback is triggered?

I need to send emails asychronously through a console application. I need to do some DB updates on the callback but my application is exiting before the callback code gets run! How can I stop this from happening in a nice manner rather than simply…
James
  • 80,725
  • 18
  • 167
  • 237
7
votes
1 answer

How can I send email asynchronously from a MVC 3 application?

In my MVC 3 Razor application, an ActionResult Create() method in the Controller handles a user HttpPost. At that point: Data is saved to a database. Emails are sent to interested parties using another project in the solution. A Confirmation page…
Arnold
  • 515
  • 1
  • 9
  • 18
7
votes
2 answers

Intercept C# HttpClient GetAsync

I have a web project (C#, MVC5 but no WebAPI) and a simple HTTP REST client that is calling an external REST service and acquires an accessToken etcing. I want to check the response from all my Get/PostAsync calls for statusCode 401 but I see that I…
maria
  • 73
  • 1
  • 1
  • 6
5
votes
3 answers

ASP.NET MVC: Send email using SendAsync (System.Net.Mail)

is there any way in MVC to get the System.Net.Mail SendAsync to work, instead of the blocking Send method? I tried using it but hit the "Page starting an asynchronous operation has to have the Async attribute" error, which I obviously can't resolve…
Alex
  • 75,813
  • 86
  • 255
  • 348
4
votes
2 answers

MVCMailer SendAsync and deleting attachments

I'm having trouble getting MVCMailer to delete attachments after sending an email asynchronously. I can't figure out what to do to dispose of the message to free up processes attached to the message attachments. Following the instructions here.... …
James South
  • 10,147
  • 4
  • 59
  • 115
4
votes
5 answers

Using Asp.Net to SendAsync emails but Page still waits?

I don't want the user to wait for page completing the sending processes, so I'm thought of using SendAsync in ASP.NET 3.5. But for after debuging, I found that the Main Thread still waits. Main: Call send email function... mailSend:…
Jerad
  • 709
  • 5
  • 11
4
votes
2 answers

C# Windows Forms ping.SendAsync issues with DataGridView

So I have this code below. I found a preview post and was working of it from here. But for some reason it is not cycling through and updating the cells with the reply status. It only updates the last ip in the list. private static void…
Zach Schulze
  • 304
  • 1
  • 4
  • 17
4
votes
1 answer

Possible problems with using Async="true" on ASP.Net Page without certain need

For example, I have some exception processing code in Global.asax, where I call the SendAsync() method of SmtpClient to notify myself about the error. If the Async property of the certain page is "false", I receive no letter. So, to fix it, do I…
3
votes
3 answers

How to use Socket.SendAsync to send large data

private void ProcessReceive(SocketAsyncEventArgs e) { // Check if the remote host closed the connection. if (e.BytesTransferred > 0) { if (e.SocketError == SocketError.Success) { Token token = e.UserToken as…
DannyQiu
  • 31
  • 1
  • 1
  • 2
3
votes
1 answer

Does all methods of HttpClient internally invoke SendAsync method?

Does all methods of HttpClient i.e. GetAsync, PostAsync etc. internally invoke SendAsync method?
shou
  • 143
  • 1
  • 1
  • 6
3
votes
2 answers

Checking whether SendAsync has finished sending

As in the simplified code below, is checking that SendAsync() has finished transmitting all intended bytes in the buffer the correct thing to do? Or is that redundant? This is for a TCP connection socket. I am particularly concerned with having to…
Nicholas
  • 1,392
  • 16
  • 38
3
votes
2 answers

C# is it safe to ping server (in local network) from 200 client PCs every 5 seconds?

I'm building an app (client) in C# which pings a server in my local network using Ping.SendAsync(host, 3000, null) to verify connectivity and send data. The app will be installed in about 200 PCs. Question is: Is it safe to ping the server every…
user1693287
  • 33
  • 1
  • 2
2
votes
4 answers

how to stop application from quiting before the mail is send through SmtpMailClient.SendAsync()

I have a issue with sending mail via SmtpMailClient.SendAsync(), i.e. if the application is closed immediately after SmtpMailClient.SendAsync(), mail is not sent. So how to force the app not to close till the callback ? Thanks !!
1
2 3 4 5 6