This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace UIKit | |
{ | |
/// <summary> | |
/// Xamarin.IOS extension that gets the parent <see cref="UITableView"/> from the <see cref="UITableViewCell"/> | |
/// </summary> | |
/// <seealso cref="https://stackoverflow.com/questions/15711645/how-to-get-uitableview-from-uitableviewcell"/> | |
public static class UITableViewCell_GetTableView | |
{ | |
/// <summary> | |
/// Gets the parent <see cref="UITableView"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace UIKit | |
{ | |
public static class UITableView_SelectCell | |
{ | |
public static void SelectCell(this UITableView @this, UITableViewCell cell) | |
{ | |
var index = @this.IndexPathForCell(cell); | |
@this.SelectRow(index, true, UITableViewScrollPosition.None); | |
@this.Delegate.RowSelected(@this, index); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
using Foundation; | |
namespace UIKit | |
{ | |
public static class UITableView_ScrollToAndSelectRow | |
{ | |
private static TimeSpan CabalisticDelay => TimeSpan.FromSeconds(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using MonoTouch.MessageUI; | |
using MonoTouch.UIKit; | |
namespace MyApp | |
{ | |
public interface ICanCleanUpMyself | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://stackoverflow.com/questions/25532870/xamarin-ios-memory-leaks-everywhere?rq=1 | |
public static void DisposeEx(this UIView view) { | |
const bool enableLogging = false; | |
try { | |
if (view.IsDisposedOrNull()) | |
return; | |
var viewDescription = string.Empty; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Threading; | |
namespace System.Globalization | |
{ | |
public static class CultureInfo_Setters | |
{ | |
public static void SetForApplication(this CultureInfo @this) | |
{ | |
@this.SetForCurrentThread(); | |
@this.SetForThreadPoolThreads(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static async void FireAndForget(this Task task) | |
{ | |
try | |
{ | |
await task; | |
} | |
catch (Exception e) | |
{ | |
// log errors | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void async Main(string[] args) | |
{ | |
try | |
{ | |
await ThrowExceptionAfterAsync(); | |
} | |
catch(Exception e) | |
{ | |
//Gonna catch SHU | |
Console.WrileLine(e.Message);//SHU |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void async Main(string[] args) | |
{ | |
await FireAndForget(); | |
Console.WriteLine("Caller"); | |
FireAndForget(); | |
Console.WriteLine("Caller"); | |
} | |
public static async Task FireAndForget() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
var result = await SumAsync(1,2); | |
Console.WriteLine(result); | |
} | |
public static int Sum(int a, int b) => a + b; | |
public static Task<int> SumAsync(int a, int b) => Task.Run(() => Sum(a, b)); |