Answer the question
In order to leave comments, you need to log in
ASP.NET trigger event on main thread?
Briefly:
There is an application, in the main thread all the necessary resources, i.e. sessions and services.
In a separate thread I listen to a specific URL and when it says do the job.
You need to do the work on the main thread.
tried events and backgroundworker all they do is execute everything in a child thread...
static Action<object> listeningOrchard = (object sender) =>
{
while (true)
{
///ждем обновлений
var needUpdate = false;
try
{
using (var client = new WebClient())
{
client.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
var text = client.DownloadString("http://localhost:8000/UpdateListener");
bool.TryParse(text, out needUpdate);
client.Dispose();
}
}
catch (Exception ex)
{
}
if (!needUpdate)
{
}
else
{
//тут должен быть вызов метода из основного потока
}
}
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question