Announcement

Collapse
No announcement yet.

async function

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • erwin
    started a topic async function

    async function

    Hi,

    we use your product since 2 years.
    We had the possibility with bridge.net to make a big change
    from silverlight to html5/javascript.

    It function all verry well.

    But, what we do not like is the structure from the async functions
    with the many 'switch'-points. The debugging is verry effortly.

    Is it planned to do here an optimization ?

    Thank you,

  • erwin
    replied
    thank you !

    Leave a comment:


  • geoffrey.mcgill
    replied
    Okay. I see. We'll keep your request in mind for a future release.

    Leave a comment:


  • erwin
    replied
    Hi,

    what do you mean with 'support IE 11' ?

    I don' need support IE.

    Bye,

    Leave a comment:


  • geoffrey.mcgill
    replied
    I see. How would you support IE 11? Or, do you feel support for IE 11 should be dropped at this point?

    Please use [CODE] tags when posting code samples.

    Leave a comment:


  • erwin
    replied
    Hi,

    i mean the structure from js and c function should be a little identical,
    not like in the following example:

    c#

    static async Task<STask> PTaskWork(STask ParTask)
    {
        string VarProg = "PTaskWork";
    
        try
        {
            ParTask.Ok = false;
    
            switch (ParTask.Aktion)
            {
                case CAktionLogin:
    
                await api.PTextMsgAllSnap();
    
                if (ParTask.MsgTextOk == true)
    
                if (gl.GlApp.Site == AppSite.Time)
                    await PKundenInfo();
                else
                {
                    ParTask.InfDatOk = true;
                    gl.GlLizenzDatei = "7.0";
                }
    
                ParTask.Ok = true;
    
                break;
            }
        }
        catch (Exception ex)
        {
            db.errLog(VarProg, ex.GetType() + ex.StackTrace);
        }
    
        return ParTask;
    }
    JS:

    PTaskWork: function (ParTask) {
        var $step = 0,
        $task1,
        $taskResult1,
        $task2,
        $taskResult2,
        $jumpFromFinally,
        $tcs = new System.Threading.Tasks.TaskCompletionSource(),
        $returnValue,
        VarProg,
        $t,
        ex,
        $async_e,
        $async_e1,
        $asyncBody = Bridge.fn.bind(this, function () {
        try {
            for (; {
                $step = System.Array.min([0,1,2,3,4,5,6,7,9,10,11,12], $step);
                switch ($step) {
                    case 0: {
                        VarProg = "PTaskWork";
                        $step = 1;
                        continue;
                    }
                    case 1: {
                        ParTask.Ok = false;
    
                        $t = ParTask.Aktion;
                        if ($t === gecomain.App.CAktionLogin) {
                            $step = 2;
                            continue;
                        }
                        $step = 10;
                        continue;
                    }
                    case 2: {
                        $task1 = gecoapi.api.PTextMsgAllSnap();
                        $step = 3;
                        $task1.continueWith($asyncBody);
                        return;
                    }
                    case 3: {
                        $taskResult1 = $task1.getAwaitedResult();
                        if (ParTask.MsgTextOk === true) {
                            $step = 4;
                            continue;
                        }
                        $step = 9;
                        continue;
                    }
                    case 4: {
                        if (gecoapi.gl.GlApp.Site === gecoapi.AppSite.Time) {
                            $step = 5;
                            continue;
                        } else {
                            $step = 7;
                            continue;
                        }
                    }
                    case 5: {
                        $task2 = gecomain.App.PKundenInfo();
                        $step = 6;
                        $task2.continueWith($asyncBody);
                        return;
                    }
                    case 6: {
                        $taskResult2 = $task2.getAwaitedResult();
                        $step = 8;
                        continue;
                    }
                    case 7: {
                        ParTask.InfDatOk = true;
                        gecoapi.gl.GlLizenzDatei = "7.0";
                        $step = 8;
                        continue;
                    }
    
                    case 9: {
                        ParTask.Ok = true;
                        $step = 10;
                        continue;
                    }
                    case 10: {
                        $step = 12;
                        continue;
                    }
                    case 11: {
                        gecoapi.db.errLog(VarProg, System.String.concat(Bridge.getTypeName(Bridge.get Type(ex)), ex.StackTrace));
                        $async_e = null;
                        $step = 12;
                        continue;
                    }
                    case 12: {
                        $tcs.setResult(ParTask.$clone());
                        return;
                    }
                    default: {
                        $tcs.setResult(null);
                        return;
                    }
                }
            }
        } catch($async_e1) {
            $async_e = System.Exception.create($async_e1);
            if ( $step >= 1 && $step <= 10 ) {
                ex = $async_e;
                $step = 11;
                $asyncBody();
                return;
            }
            $tcs.setException($async_e);
        }
        }, arguments);
    
        $asyncBody();
        return $tcs.task;
    },
    Thank you,
    Last edited by geoffrey.mcgill; 2019-01-11 @ 05:57 PM.

    Leave a comment:


  • geoffrey.mcgill
    replied
    Hi erwin,

    Thanks for the feedback.

    Can you propose a JavaScript pattern to handle the async functionality they way you feel it should be implemented?

    Leave a comment:

Working...
X