Posts
What is asynchronous programming?
- software often waits for some I/O operation to complete (file operation, network call, database query etc.)
- we can use this time for something productive instead to wait for data to be available or I/O operation to be completed
- with asynchronous programming user can work in the meantime
- not waiting for I/O operations synchronously enhances user experience
Of course this problem is much more complex. Modern software operates on much more different PC architecture than 20 years ago. Nowadays software must be asynchronous to appear more user friendly and to made better use of modern multi CPU architecture. Right now complex, professional software uses multiple processes, threads on multiple CPUs (CPU you buy is not really *single* CPU) or even utilize GPU for more complex computations (like i.e. video editing software). Before that we mostly had single threaded desktop applications that had ‘please wait’ or ’loading’ pop ups. Right now this is song of the past really and to achieve better User Interfaces that allow to edit tag of your post without changing whole post. With mobile devices on the rise and sometimes lousy cellular network those kind of designs would not be sensible or sometimes impossible to implement. Did you ever happened to reenter some chunk of data into some software because you lost it? Maybe network was down? Or you hit back button by mistake? Right now it belongs to past mostly. All of those would be hard to do with synchronous operations. Right now people are bit spoiled and they tend to leave the page/application if it appears to be slow and not every company can sell ‘one-in-the-market-necessary-for-your-work-software’ that you will be forced to use. And this is why we have asynchronous operations and this is why we have asynchronous programming model that allows us to program such operations.
Dynamic runtime delegates conversion
Introduction
Delegates can be converted easily to another type if you know types of those delegates. But if you do not know it is impossible without really complicated code.
Automatic scrolling to edited text box in Xamarin Android.
Important note: this should work well with newer version of Xamarin (2.3.3). If you cannot update for some reason this article will explain workaround.
Introduction
In previous article I explained how to detect show and hide events of software keyboard in Xamarin Android. I did it in my project because of the fact that some of text boxes was hidden by software keyboard that suppose to edit contents of those text boxes. In this article I will explain how to work around this issue in some older versions of Xamarin.
Detecting software keyboard events in Xamarin Android
#delegates #dependency injection #design patterns
Introduction
It is quite strange that you can’t easily detect if software keyboard is visible or not on Android. Because of that, it is also complicated thing to do in Xamarin.
Xamarin Android Services Pattern on GPS example
#design patterns #XAML #dependency injection
Introduction
In Xamarin if you want to use many Android native service/mechanism you have to implement it in Activity class. Or at least that is how Xamarin documentation wants you to do it.
Xamarin with TinyIoC
#XAML #dependency injection #Xamarin
Introduction
This article is builds on topics and solutions introduces in ViewFactory for Xamarin application and Xamarin Master-Detail Page articles. It shows method for easier navigation and use of services via IoC in Xamarin application. Knowledge from previous examples is not necessary, but makes this article bit easier to understand.
Genereting proxies during runtime using Reflection.Emit
#reflection #self-hosting #delegates #XAML
Reflection.Emit is very powerful tool. It creates IL code and since C# is converted into IL too, we have the same functionality as in C# and even more. It is very powerful and at the same time very complicated. Because of that it is worth to discuss how and for what it should be used. One idea is to create dynamic code with automatic implementations of interfaces - proxy types.
Faster than Reflection: Delegates. Part 3.
#delegates #reflection #generics #NuGet
This is third article in series, that explains how to create delegates for public and non-public members of public, non-public or not known in compile-time types. If you are not familiar with previous articles and looking for detailed explanation of how delegates works, how they are created and why, I strongly encourage you to read first two. If you are just looking for a way to create delegates for methods or constructors it is not necessary. Code with new features and with bug fixes is available on GitHub and as Nuget package.
Faster than Reflection: Delegates. Part 2.
This is second article in series, that explains how to create delegates for public and non-public members of public, non-public or not known in compile-time types. If you are not familiar with previous article and looking for detailed explanation of how delegates works, how they are created and why, I strongly encourage you to read it first. If you are just looking for a way to create delegates for methods or constructors it is not necessary. Last article in series you can find here . Code with new features and with bug fixes is available on GitHub and as Nuget package. In previous article and first one in series, we covered:
- Static
- Properties
- Fields
- Instance
- Properties
- Fields
- Indexers
Now it is time to cover following members.
- Static
- Methods
- Instance
- Methods
- Constructors
Faster than Reflection: Delegates. Part 1.
This article is first part of the series of three. Next ones you can find here and here . Code for all three articles, with new features and bug fixes is available on GitHub and as Nuget package.
Why not Reflection?
If you working with .NET and C# (probably other languages too), at some point, you will have to write more advanced and generic code, that i.e. reads all properties of a type, searches for attributes, etc. Or maybe you want to call some private method or property? It is not that rare to use some internal mechanism of framework or library. Usually, the first solution involves Reflection. But the thing is: Reflection is slow. Of course, it is sufficient if you need to use Reflection rarely and it is not the main code of the application. If it is used more often at some point, you will probably try to optimize it. And now is the fun part: how to do it?
ViewFactory for Xamarin application
#delegates #reflection #async #XAML
First things first - Why?
First of all I do not like how creating of views and navigation works in Xamarin. There is much boilerplate needed to just navigate from one page to another. Typically like in Xamarin documentation
we have to obtain INavigation interface instance, create instance of a new page, create instance of view model and all dependencies it requires. When you page do not require view model things are real easy and Xamarin sample is just enough.
Xamarin Master-Detail Page
#XAML #design patterns #Xamarin
This article as previous ones (Frame With Padding , Frame Outline Problem , Inheritance from Implicit Styles ) also will be about Xamarin. This time we will inspect Master-Detail page control/mechanism. You can find official documentation for this control here . Quick spoiler: I never used this in any production application. Why? I will explain. Whole article will be to explain why this is just not worth your time. In this and subsequent articles I will introduce much better solution.
Xamarin Style based on implicit Style
Next article about bugs in Xamarin will touch topic of Styles. Styles for all of controls not only Frame (and if you wondering why Frame you should check first two articles about Xamarin here and here) . First of all if you are using Styles in Xamarin you probably know how to define implicit styles. If not here is a sample:
<Application.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="FontSize" Value="45" />
</Style>
</ResourceDictionary>
</Application.Resources>
Xamarin Frame and disappearing Outline
This is another article in mini series of Xamarin bugs and workarounds for them :) Previous one you can find here . This one is again about Frame control. I promise that another one will be about something else B) Issue can be observed when you bind BackgroundColor property of Frame control and something will trigger change of view model source property binded to background color.