question

chbernard avatar image
0 Votes"
chbernard asked RobCaplan edited

Task httpclient -> call just one time ?

Hello,
I have an app under xamarin android who call a controller in http and get some information ..
All works fine BUT sometimes we notice we have the same call in the same hour / sec

For to resume, inside the controller i have a log who trace the begin of the call and the end of the call
And i don't know why but sometimes for the same device , the call http is like DUPLICATE multiple time ...

Any idea about how to solve this ?

thanks

dotnet-xamarin
· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,chbernard. Where do you call the controller? Do you place the code in a lifecycle method? You could add a breakpoint to check if the code is executed multiple times.

1 Vote 1 ·

Hello @JarvanZhang-MSFT

thanks for comment
here is it few code how it's call

protected override bool OnViewBecomeActive(View root)
{
Task.Run(() => CreateInvoice(createInvoiceParamaters));
}

and inside the createInvoice method we have this:


public void CreateInvoice(CreateInvoiceParamaters createInvoiceParamaters)
{
var url = App.Config.GetInvoiceEndpoint(xxxxxxxxxxx);
var result = HttpService.Get<InvoiceResult>(url);

     // ...

}

Me, each time i try it's call one time ..until now i can t reproduce this case ..
I try to find solution but until now i can't ...

Any idea , suggestion are welcome

thanks

0 Votes 0 ·

Sorry, what is the 'OnViewBecomeActive' method? I could not get the related info about the method. I mean where the function code is called in the xamarin.Android project.

0 Votes 0 ·

Hello @JarvanZhang-MSFT

yes exactly it's xamarin android and its a fragment -> and it's method it's call on OnCreateView

thanks for your research ..i'm trying again but without succedeed to reproduce this case ..

It's strange i m not expert but thanks for your time

0 Votes 0 ·
Show more comments

1 Answer

chbernard avatar image
0 Votes"
chbernard answered JarvanZhang-MSFT commented

IHello @JarvanZhang-MSFT

I"ve find :)
In fact, it's an pagerAdater who load multiple fragment and the life cycle for all was not good ..

as this, we spend some in multiple time in the call http

thanks for your help

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.