I have a WPF C# application, in which a certain function takes quite a long time for performing its operation.
int result = MyFavFunctions.mainfunction(searchquery);
I want to perform the calculation for this function on a separate thread, and not block the UI thread. In addition, before I get the result of this operation, I don’t want to proceed with further in the function because int result is what I am using further.
Can this be done with threading?
In addition, I also am not sure because the functions in this mainfunction is actually exported function from a C++ dll. So, after this main function, if I use other exported functions in the dll (which are just used to fetch values), will they have the appropriate result?
Yes threading is how that would be achieved – have a look at http://msdn.microsoft.com/en-us/magazine/cc163328.aspx for some useful info, in particular what you want is the BackgroundWorker ( http://msdn.microsoft.com/en-us/magazine/cc163328.aspx#S4 ).
As to the results from the fetch functions – that is very much dependant on how the dll is implemented – if it is intended to be used that way then they should work ok – it is trivial to put together a scratch test application to verify this.