I am using SAP.NET Connector 3.0 and trying to log in using a separate thread so that I can display the user interface for my kind of login animation.
I use Async and Await to start the login, but the user interface freezes for about 10 seconds during the login.
Here is the code, this is rude because I am developing a program quickly.
async void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
Busy.Visibility = System.Windows.Visibility.Visible;
if (await SAPLogin())
{
await GetData();
Busy.Visibility = System.Windows.Visibility.Collapsed;
}
}
private Task<bool> SAPLogin()
{
bool LoggedIn = true;
return Task.Run(() =>
{
Backend = new BackendConfig();
RfcDestinationManager.RegisterDestinationConfiguration(Backend);
SapRfcDestination = RfcDestinationManager.GetDestination(MyServer);
SapRap = SapRfcDestination.Repository;
BapiMD04 = SapRap.CreateFunction("MD_STOCK_REQUIREMENTS_LIST_API");
BapiMD04.SetValue("WERKS", "140");
return LoggedIn;
});
}
Can I just imagine that something in the Task is using the user interface?
1:
, , GetData().
GetData() SAP ( ). , , , " " " ".
, , , " ". . , 5 .
2:
,
SapRfcDestination = RfcDestinationManager.GetDestination(MyServer);
3:
, , .