Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

FireTracking Event Made Async #1

Merged
merged 1 commit into from

2 participants

@troelsrichter

FireTracking event made async but i enden up using the version from your website instead of the git hub version. it looked like the one on your website was newer?

@dougrathbone dougrathbone merged commit 7afbc6f into dougrathbone:master
@dougrathbone
Owner

thanks mate!

You've made me excited to get back into it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 48 additions and 5 deletions.
  1. +48 −5 GaDotNet.Common/Tracking/GoogleTracking.cs
View
53 GaDotNet.Common/Tracking/GoogleTracking.cs
@@ -18,6 +18,7 @@
*/
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Net;
using System.Text;
@@ -75,10 +76,52 @@ private static void ShowTrackingImage(HttpContext context)
/// <param name="request">The request.</param>
public static void FireTrackingEvent(TrackingRequest request)
{
-
- //send the request to google
- WebRequest requestForGaGif = WebRequest.Create(request.TrackingGifUri);
- WebResponse response = requestForGaGif.GetResponse();
+ WebRequest requestForGaGif = WebRequest.Create(request.TrackingGifUri);
+ requestForGaGif.BeginGetResponse(r =>
+ {
+ try
+ {
+ var reponse = requestForGaGif.EndGetResponse(r);
+ //ignore response
+ }
+ catch
+ {
+ //suppress error
+ }
+ }, null);
}
- }
+
+
+ private static void ResponseCallback(IAsyncResult result)
+ {
+
+ }
+
+
+
+ }
+
+
+
+
+
+ public class RequestState
+ {
+ public int BufferSize { get; private set; }
+ public StringBuilder ResponseContent { get; set; }
+ public byte[] BufferRead { get; set; }
+ public HttpWebRequest Request { get; set; }
+ public HttpWebResponse Response { get; set; }
+ public Stream ResponseStream { get; set; }
+
+ public RequestState()
+ {
+ BufferSize = 1024;
+ BufferRead = new byte[BufferSize];
+ ResponseContent = new StringBuilder();
+ Request = null;
+ ResponseStream = null;
+ }
+ }
+
}
Something went wrong with that request. Please try again.