Bug 25000 - Logical context is lost after async calls to GetAsync(url) on Android
Summary: Logical context is lost after async calls to GetAsync(url) on Android
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: unspecified
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-12-02 11:53 UTC by Michael
Modified: 2016-12-22 21:26 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Michael 2014-12-02 11:53:42 UTC
To reproduce the issue run the following code in Android using ModernHttpClient. Id2 will be null when it should be "123."

CallContext.LogicalSetData("id", "123");
var id1 = CallContext.LogicalGetData("id");
var dataResponse = await httpClient.GetAsync(url);
var id2 = CallContext.LogicalGetData("id");

This works fine on iOS but on Android does not (I am using the new Xamarin Android Player running Nexux 4 (KitKat) Android 4.4.2 - API 19. Also if I switch the client to standard .NET HttpClient, everything works even on Android.
Comment 1 Rajneesh Kumar 2014-12-22 03:22:33 UTC
I have checked this issue but I am unable to reproduce this issue .

Steps I followed:

1. Create an android application on XS
2. Write the following code in button event handler

 var url="https://www.google.com";
                var httpClient = new HttpClient(new NativeMessageHandler());

                CallContext.LogicalSetData("id", "123");
                var id1 = CallContext.LogicalGetData("id");              
                var dataResponse = await httpClient.GetAsync(url);
                var id2 = CallContext.LogicalGetData("id");

                button.Text = string.Format("{0} clicks!", count++);

 3. Set a break point on following line

  button.Text = string.Format("{0} clicks!", count++);

4. Build and deploy application on XAP ( Nexus 4 KitKat 4.4.2- API 19) 
5. Tap the button to hit the breakpoint.
6. Check the values if id2 variable.

When I hover cursor over the id2 variable it shows the value of id1 variable, i.e. 123.

Screencast: http://www.screencast.com/t/vJpWisKpkGf4

Could you please provide sample application and build info? So that we can reproduce this issue at our end. 

Environment Info:

=== Xamarin Studio ===

Version 5.7 (build 660)
Installation UUID: 6ea47b0d-1852-4aaf-808d-373ff0a5002b
Runtime:
	Mono 3.12.0 ((detached/c82a2e5)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000070

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: 8.6.0.41 (Trial Edition)
Hash: 2c57f4e
Branch: 
Build date: 2014-12-18 16:42:49-0500

=== Xamarin.Android ===

Version: 4.20.0.28 (Trial Edition)
Android SDK: /Users/jatin66/Desktop/Backup/android-sdk-macosx
	Supported Android versions:
		1.6    (API level 4)
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin.Mac ===

Version: 1.10.0.18 (Starter Edition)

=== Build Information ===

Release ID: 507000660
Git revision: 6a74f9bdb90d9415b597064d815c9be38b401fee
Build date: 2014-12-18 00:38:00-05
Xamarin addins: 57be0f5e1433cb58b70ea9b52e9dc77ad791be40

=== Operating System ===

Mac OS X 10.10.0
Darwin Jatin66s-iMac.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 Jose Gallardo 2016-12-22 21:26:21 UTC
Marking as RESOLVED / NORESPONSE
Please feel free to reopen it if needed.