Exemplo n.º 1
0
        public static Task <bool> InitLoggingAsync()
        {
            return(Task.Run(
                       () => {
                var tcs = new TaskCompletionSource <bool>();
                InitLoggingCb cb2 = null;
                cb2 = (ptr, result) => {
                    if (result.ErrorCode != 0)
                    {
                        tcs.SetException(result.ToException());
                        CallbackManager.Unregister(cb2);
                        return;
                    }

                    tcs.SetResult(true);
                    CallbackManager.Unregister(cb2);
                };
                CallbackManager.Register(cb2);

                AppOutputLogPathCallback cb1 = null;
                cb1 = async(ptr, result, path) => {
                    if (result.ErrorCode != 0)
                    {
                        tcs.SetException(result.ToException());
                        CallbackManager.Unregister(cb1);
                        CallbackManager.Unregister(cb2);
                        return;
                    }

                    var appPath = Path.GetDirectoryName(path);
                    var fileList = new List <Tuple <string, string> > {
                        Tuple.Create("log.toml", Path.Combine(appPath, "log.toml"))
                    };

                    var fileOps = DependencyService.Get <IFileOps>();
                    await fileOps.TransferAssetsAsync(fileList);

                    Debug.WriteLine("Assets Transferred");
                    NativeBindings.AppInitLogging(null, UserData, cb2);
                    CallbackManager.Unregister(cb1);
                };

                CallbackManager.Register(cb1);
                NativeBindings.AppOutputLogPath("test_file", UserData, cb1);
                return tcs.Task;
            }));
        }
Exemplo n.º 2
0
 public static extern void AppOutputLogPathNative(string fileName, IntPtr userDataPtr, AppOutputLogPathCallback callback);
Exemplo n.º 3
0
 public void AppOutputLogPath(string fileName, IntPtr userDataPtr, AppOutputLogPathCallback callback)
 {
     AppOutputLogPathNative(fileName, userDataPtr, callback);
 }