Itu udah lama prosesnya, malah programnya gak bisa diapa-apain, kalo di klik
bisa not responding, setelah dibiarkan beberapa lama, baru hasil perhitungan
huruf vokalnya keluar.
Maksud saya disini yang gak ngefek, prosesnya dah lama, saya mau menjalankan
proses lain ketika mengunggu proses itu, misalnya ada lg tombol lain untuk
menampilkan pesan atau yg lain, tp tidak menunggu proses perhitungan huruf
vokalnya selesai dulu.
________________________________
Dari: nickotech2000 <[email protected]>
Kepada: "[email protected]" <[email protected]>
Dikirim: Rabu, 20 Juli 2011 10:24
Judul: Re: [Mugi] Nanya tentang Asynchronous di C#
Coba kalau processnya dibikin lama?
Ngefek ga? process yang di async? :)
Best Regards,
Nicko Satria Utama, MCTS
blogs : http://nickotech2000.blogspot.com
From: Yakin Zure <[email protected]>
To: "[email protected]" <[email protected]>
Sent: Wednesday, 20 July 2011, 9:02
Subject: [Mugi] Nanya tentang Asynchronous di C#
Mau nanya nih, apa sih keuntungan menggunakan Asynchronous Method ketimbang
yang gak make? dan Bagaimana caranya misalnya kita memproses sesuatu yang lama
prosesnya, misalnya menghitung huruf konsonan pada sebuah kalimat yang panjang,
trus bisa tidak disaat proses menghitung tersebut kita jalankan proses yg lain
tanpa terbebani oleh proses perhitungan huruf konsonan tsb?
saya dah nyoba pake Async tapi kok gak ngefek ya?
Misalnya codingnya seperti ini :
======================================================
delegate int AsyncProsesHitung();
public int AsyncHitungVokal()
{
AsyncProsesHitung AsyncVokal = new AsyncProsesHitung(HitungVokal);
IAsyncResult iar = AsyncVokal.BeginInvoke(null, null);
while (!iar.IsCompleted)
{
//Lakukan hal lain tanpa terpengaruh Proses diatas
}
int Hasil = AsyncVokal.EndInvoke(iar);
return Hasil;
}
public int HitungVokal()
{
int jmlVokal = 0;
for (int i = 1; i <= this.Content.Characters.Count; i++)
{
if (this.Content.Characters[i].Text.ToLower() == "a" ||
this.Content.Characters[i].Text.ToLower() == "i" ||
this.Content.Characters[i].Text.ToLower() == "u" ||
this.Content.Characters[i].Text.ToLower() == "e" ||
this.Content.Characters[i].Text.ToLower() == "o")
{
jmlVokal++;
}
}
return jmlVokal;
}
=============================================
_______________________________________________
To unsubscribe from this group, send an email to:
[email protected]
Get Free 5 GB mailbox Check this http://www.mugi.or.id
Powered by bisnismedia.com
_______________________________________________
To unsubscribe from this group, send an email to:
[email protected]
Get Free 5 GB mailbox Check this http://www.mugi.or.id
Powered by bisnismedia.com_______________________________________________
To unsubscribe from this group, send an email to:
[email protected]
Get Free 5 GB mailbox Check this http://www.mugi.or.id
Powered by bisnismedia.com