Sto creando un'applicazione console, in cui è necessario chiamare un metodo, che eseguirà un elenco di LAVORI. Ma voglio che questo metodo non abbia alcun impatto sull'applicazione principale, semplicemente farà i lavori ... tutto qui..net C#: Creazione di un processo asincrono
5
A
risposta
1
Date un'occhiata a this article.
Esempio:
using System;
using System.Threading;
public class ServerClass
{
// The method that will be called when the thread is started.
public void InstanceMethod()
{
Console.WriteLine(
"ServerClass.InstanceMethod is running on another thread.");
// Pause for a moment to provide a delay to make
// threads more apparent.
Thread.Sleep(3000);
Console.WriteLine(
"The instance method called by the worker thread has ended.");
}
public static void StaticMethod()
{
Console.WriteLine(
"ServerClass.StaticMethod is running on another thread.");
// Pause for a moment to provide a delay to make
// threads more apparent.
Thread.Sleep(5000);
Console.WriteLine(
"The static method called by the worker thread has ended.");
}
}
public class Simple{
public static int Main(String[] args)
{
Console.WriteLine("Thread Simple Sample");
ServerClass serverObject = new ServerClass();
// Create the thread object, passing in the
// serverObject.InstanceMethod method using a
// ThreadStart delegate.
Thread InstanceCaller = new Thread(
new ThreadStart(serverObject.InstanceMethod));
// Start the thread.
InstanceCaller.Start();
Console.WriteLine("The Main() thread calls this after "
+ "starting the new InstanceCaller thread.");
// Create the thread object, passing in the
// serverObject.StaticMethod method using a
// ThreadStart delegate.
Thread StaticCaller = new Thread(
new ThreadStart(ServerClass.StaticMethod));
// Start the thread.
StaticCaller.Start();
Console.WriteLine("The Main() thread calls this after "
+ "starting the new StaticCaller thread.");
return 0;
}
}
1
Dai un'occhiata alla
Problemi correlati
- 1. Chiamate di processo asincrono
- 2. Creazione di un file in modo asincrono
- 3. D Processo di creazione
- 4. Creazione di un processo da un driver
- 5. C# Leggi lo stdout del processo figlio in modo asincrono
- 6. Creazione di un file .dll in C# .Net
- 7. Creazione di un metodo di servizio Web asincrono
- 8. C# reindirizzare (pipe) l'output di processo a un altro processo
- 9. Creazione di un diagramma di classe C++
- 10. Creazione dell'applicazione Windows C# .net aggiornabile
- 11. È specificato il processo di trasformazione asincrono/atteso?
- 12. Creazione di un servizio CalDAV con .Net
- 13. Libreria server .NET WebSocket con supporto asincrono.
- 14. Creazione EPUB in .Net
- 15. Creazione di un servizio REST con C#
- 16. Creazione di un file vuoto in C#
- 17. Come allegare un debugger alla creazione del processo?
- 18. avvio di un processo da un servizio Windows .NET
- 19. Il processo asincrono ha inizio e aspetta che finisca
- 20. Modificatore asincrono in C#
- 21. Come reindirizzare in modo asincrono SOLO il flusso di errore standard e non il flusso di output standard di un processo in C#, .net
- 22. Ottenere risultato di .Net oggetto metodo asincrono in PowerShell
- 23. Il GC .NET funzionerà con un oggetto abbandonato che esegue un metodo in modo asincrono?
- 24. Processo eseguibile .NET walk through
- 25. Config.xml ignorato nel processo di creazione
- 26. Come chiamare una DLL .NET da un processo Win32?
- 27. Creazione di un server di automazione COM in C#
- 28. Come uccidere un processo C#?
- 29. Processo di fork con CC .NET
- 30. Rails Creazione di un nuovo thread o processo in background
E che cosa quei lavori assomigliano? Qualche dato condiviso? –