async-await

how to catch exit signal in asp.net core on linux?

两盒软妹~` 提交于 2021-01-28 10:43:00
问题 I am writing a c# console app base on net core 3.1 linux It was expected to run job async await job end catch the kill signal and do some clean job here is my demo code: namespace DeveloperHelper { public class Program { public static async Task Main(string[] args) { var http = new SimpleHttpServer(); var t = http.RunAsync(); Console.WriteLine("Now after http.RunAsync();"); AppDomain.CurrentDomain.UnhandledException += (s, e) => { var ex = (Exception)e.ExceptionObject; Console.WriteLine(ex

how to catch exit signal in asp.net core on linux?

橙三吉。 提交于 2021-01-28 10:37:04
问题 I am writing a c# console app base on net core 3.1 linux It was expected to run job async await job end catch the kill signal and do some clean job here is my demo code: namespace DeveloperHelper { public class Program { public static async Task Main(string[] args) { var http = new SimpleHttpServer(); var t = http.RunAsync(); Console.WriteLine("Now after http.RunAsync();"); AppDomain.CurrentDomain.UnhandledException += (s, e) => { var ex = (Exception)e.ExceptionObject; Console.WriteLine(ex

how to catch exit signal in asp.net core on linux?

怎甘沉沦 提交于 2021-01-28 10:35:02
问题 I am writing a c# console app base on net core 3.1 linux It was expected to run job async await job end catch the kill signal and do some clean job here is my demo code: namespace DeveloperHelper { public class Program { public static async Task Main(string[] args) { var http = new SimpleHttpServer(); var t = http.RunAsync(); Console.WriteLine("Now after http.RunAsync();"); AppDomain.CurrentDomain.UnhandledException += (s, e) => { var ex = (Exception)e.ExceptionObject; Console.WriteLine(ex

Getting an Image uri into render from an async Function

依然范特西╮ 提交于 2021-01-28 09:50:46
问题 having a bit of trouble. I should start by saying I'm really new to react native so hopefully it's not something foolish I've missed. I'm using firebase to store image uri's but when I try to pass them in render from my function it gives me the {_40:0,_65:0,_55:null,_72:null} output but in the function, it seems to get the uri just fine so it seems to be something with passing it back. I've tried using AsyncImage (using the sunglass dog example: https://www.npmjs.com/package/react-native

Should I use ConfigureAwait(false) in places like Repository?

£可爱£侵袭症+ 提交于 2021-01-28 09:14:55
问题 Just read this article about ConfigureAwait and it made me think on an issue I haven't been able to come to peace with for some time now. Consider the code below. Each dependency uses await to make the call asynchronous. My concern is that each time we exit an await it goes back to the UI thread and I don't want that until I'm actually at the top level where the UI needs to be updated in order to reduce thread context switching. That made me think that ConfigureAwait(false) should be used in

Should I use ConfigureAwait(false) in places like Repository?

*爱你&永不变心* 提交于 2021-01-28 09:10:58
问题 Just read this article about ConfigureAwait and it made me think on an issue I haven't been able to come to peace with for some time now. Consider the code below. Each dependency uses await to make the call asynchronous. My concern is that each time we exit an await it goes back to the UI thread and I don't want that until I'm actually at the top level where the UI needs to be updated in order to reduce thread context switching. That made me think that ConfigureAwait(false) should be used in

How to cancel a task using a CancellationToken and await Task.WhenAny

浪子不回头ぞ 提交于 2021-01-28 07:54:32
问题 I have web application and it calls different web service to perform different work. Some web services will take long time and some short. Application will call all web services parallel to get result when complete or exception. I have started to write code but i need to know how to implement the following works in the best way. A task will be cancelled if any of web service takes more than 5 seconds but remaining tasks will continue to call web service to get either result or excepton. I

Javascript async/await execution order problem in for…of, for await…of and Promise.all

邮差的信 提交于 2021-01-28 07:34:59
问题 For each object (product) in an array (products), I'm getting the price from a mongoose database. That value (prodDB.price) is summed to the "amount" variable initialized as 0 before the loop. I tried 3 solutions explained in other questions, with: for of for await of Promise.all --- for of --- let amount = 0; for (const product of products) { await Product.findById(product._id).exec((err, prodDB)=> { amount += product.count * prodDB.price; console.log("Current amount", amount); }); };

Firestore realtime listener to multiple documents async await

随声附和 提交于 2021-01-28 07:21:05
问题 I am wondering if the realtime listener for Firestore supports async await instead of promise? The documentation suggests: var unsubscribe = db.collection("cities").where("state", "==", "CA").onSnapshot(function(querySnapshot) { var cities = []; querySnapshot.forEach(function(doc) { cities.push(doc.data().name); }); console.log("Current cities in CA: ", cities.join(", ")); }); unsubscribe(); Could I write the above realtime listener using async await ? I tried the following and the listener

Shouldn't await force execution to wait?

爱⌒轻易说出口 提交于 2021-01-28 06:14:36
问题 I have JavaScript code that looks like this (using Sequelize in Node): if (require.main == module) { (async () => { const my_var = await MyModel.createWithChildren('name', ['one', 'two']); console.log('before'); console.log(await my_var.getChildren()); console.log('after'); })(); } MyModel has a static method that looks like this: static async createWithChildren(name, children) { const me = await Me.create({name: name}); const child_recs = await Child.bulkCreate(children.map((child) => (