public void ReportImpressionInfo(string provider, string appId, string adUnitId) { // Reason to put this part of the code in a worker thread: // 1) CPU optimization // 2) WaitOne cannot happen in UI thread or else the whole app will be hual ThreadPool.QueueUserWorkItem( state => { _ipRefreshedEvent.WaitOne(); var newAppUsage = new AppUsage(_applicationId, _anid, _deviceId, _appTitle) { AdControlDeviceId = _adControlDeviceId, AdUnitId = adUnitId, AssemblyFileVersion = _assemblyVersion, IpAddress = _ipAddress, Country = _country, Region = _region, City = _city, Isp = _isp, AppId = appId, Provider = provider, Action = "Impress" }; var table = _tableClient.GetTableReference(AppUsageTableName); table.BeginExecute(TableOperation.InsertOrReplace(newAppUsage), SaveChangesCallback, null); }); }
public void ReportErrorInfo(string provider, string appId, string adUnitId, string errorMessage) { ThreadPool.QueueUserWorkItem( state => { _ipRefreshedEvent.WaitOne(); var newAppUsage = new AppUsage(_applicationId, _anid, _deviceId, _appTitle) { AdControlDeviceId = _adControlDeviceId, AdUnitId = adUnitId, AssemblyFileVersion = _assemblyVersion, IpAddress = _ipAddress, Country = _country, Region = _region, City = _city, Isp = _isp, AppId = appId, Provider = provider, Action = "Error", Message = errorMessage }; var table = _tableClient.GetTableReference(AppUsageTableName); table.BeginExecute(TableOperation.InsertOrReplace(newAppUsage), SaveChangesCallback, null); }); }
public void ReportErrorInfo(string pubId, string adUnitId, string errorMessage) { ThreadPool.QueueUserWorkItem( state => { _ipRefreshedEvent.WaitOne(); var newAppUsage = new AppUsage(_applicationId, _anid, _deviceId, _appTitle) { AdControlDeviceId = _adControlDeviceId, AdUnitId = adUnitId, AssemblyFileVersion = _assemblyVersion, IpAddress = _ipAddress, Country = _country, Region = _region, City = _city, Isp = _isp, PubId = pubId, Action = "Error", Message = errorMessage }; _tableContext = new TableServiceContext(TableServiceUri, _credentials); _tableContext.AddObject(AppUsageTableName, newAppUsage); _tableContext.BeginSaveChanges(SaveChangesOptions.ContinueOnError, SaveChangesCallback, null); }); }
public void ReportImpressionInfo(string pubId, string adUnitId) { // Reason to put this part of the code in a worker thread: // 1) CPU optimization // 2) WaitOne cannot happen in UI thread or else the whole app will be hual ThreadPool.QueueUserWorkItem( state => { _ipRefreshedEvent.WaitOne(); var newAppUsage = new AppUsage(_applicationId, _anid, _deviceId, _appTitle) { AdControlDeviceId = _adControlDeviceId, AdUnitId = adUnitId, AssemblyFileVersion = _assemblyVersion, IpAddress = _ipAddress, Country = _country, Region = _region, City = _city, Isp = _isp, PubId = pubId, Action = "Impress" }; _tableContext = new TableServiceContext(TableServiceUri, _credentials); _tableContext.AddObject(AppUsageTableName, newAppUsage); _tableContext.BeginSaveChanges(SaveChangesOptions.ContinueOnError, SaveChangesCallback, null); }); }
public void ReportEngagedInfo(string pubId, string adUnitId) { ThreadPool.QueueUserWorkItem( state => { _ipRefreshedEvent.WaitOne(); var newPartitionKey = (DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks).ToString("d19"); var newAppUsage = new AppUsage(newPartitionKey, _anid, _deviceId, _appTitle) { AdControlDeviceId = _adControlDeviceId, AdUnitId = adUnitId, AssemblyFileVersion = _assemblyVersion, IpAddress = _ipAddress, Country = _country, Region = _region, City = _city, Isp = _isp, PubId = pubId, Action = "Engaged" }; _tableContext = new TableServiceContext(TableServiceUri, _credentials); _tableContext.AddObject(AppUsageTableName, newAppUsage); _tableContext.BeginSaveChanges(SaveChangesOptions.ContinueOnError, SaveChangesCallback, null); }); }