elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  problema para mostrar 'cargando...'
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: problema para mostrar 'cargando...'  (Leído 2,855 veces)
<[(x)]>

Desconectado Desconectado

Mensajes: 215



Ver Perfil
problema para mostrar 'cargando...'
« en: 20 Junio 2009, 23:44 pm »



holas

 Estoy armando un juego y en el momento que este carga las texturas no puedo hacer q la animación del 'cargando...' funcione fluidamente.

 Es así:
____
|
  • timercargando-activar
  • cargar texturas
|___

 El problema esta q la función cargar  texturas se compone por un for que va cargando todas las texturas y en el momento q empieza a cargar una se congela todo el programa asta q termina de cargarse.

 Como puedo hacer para q no pase esto??.

 Lo primero que se me ocurrió es armar otro ejecutable que me maneje el DC del 'cargando...'. Pero si tienen una idea mejor, espero que si, les agradeceria q me la trasmitann.

S2


En línea

<[(x)]>
Jubjub


Desconectado Desconectado

Mensajes: 708


Lay Ladie lay,...


Ver Perfil WWW
Re: problema para mostrar 'cargando...'
« Respuesta #1 en: 21 Junio 2009, 00:49 am »

Lo ideal es utilizar un thread que al no ser bloqueante, ira a la pefeccion.

Tambien puedes utilizar una animacion :)


En línea

Jugando con Fósforoshacking con un tono diferente


.
porno
Karcrack


Desconectado Desconectado

Mensajes: 2.416


Se siente observado ¬¬'


Ver Perfil
Re: problema para mostrar 'cargando...'
« Respuesta #2 en: 21 Junio 2009, 00:53 am »

No se si he entendido bien, pero con un DoEvents y un Control.Refresh creo que te sobra :P ;)
En línea

Jubjub


Desconectado Desconectado

Mensajes: 708


Lay Ladie lay,...


Ver Perfil WWW
Re: problema para mostrar 'cargando...'
« Respuesta #3 en: 21 Junio 2009, 00:55 am »

D:  y yo haciéndolo con threads.. en fin, gracias, investigare sobre ello ;)
En línea

Jugando con Fósforoshacking con un tono diferente


.
porno
<[(x)]>

Desconectado Desconectado

Mensajes: 215



Ver Perfil
Re: problema para mostrar 'cargando...'
« Respuesta #4 en: 21 Junio 2009, 01:15 am »


 Ya me pongo a ver los threads, con DoEvents no iría ni ai..
« Última modificación: 21 Junio 2009, 01:21 am por <[(x)]> » En línea

<[(x)]>
<[(x)]>

Desconectado Desconectado

Mensajes: 215



Ver Perfil
Re: problema para mostrar 'cargando...'
« Respuesta #5 en: 21 Junio 2009, 01:48 am »

mmm
    
       Por lo que leí parece q es exactamente lo que necesito. Me podrían pasar un ejemplo de thread que no logro encontrar uno  :¬¬. si pueden ser los archivos mejor...
       Y algo mas estuve viendo que se necesita agregar la referencia 'NetFx20Wrapper', la cual busque y no tengo. DE donde puedo descargarla o encontrarla ??
      
 gracias:.
« Última modificación: 21 Junio 2009, 01:52 am por <[(x)]> » En línea

<[(x)]>
XcryptOR

Desconectado Desconectado

Mensajes: 228



Ver Perfil
Re: problema para mostrar 'cargando...'
« Respuesta #6 en: 21 Junio 2009, 03:02 am »

he aquí estos módulos de clase que te ayudaran con tu problema

Código
  1. 'clsThreading:
  2. 'Simple class that allows you to implement multithreading in your app
  3. '
  4. '(C) 2001 by Philipp Weidmann
  5.  
  6. 'API Declarations
  7. 'Creates a new thread
  8. Private Declare Function CreateThread Lib "kernel32" (ByVal lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
  9. 'Terminates a thread
  10. Private Declare Function TerminateThread Lib "kernel32" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long
  11. 'Sets the priority of a thread
  12. Private Declare Function SetThreadPriority Lib "kernel32" (ByVal hThread As Long, ByVal nPriority As Long) As Long
  13. 'Returns the proirity of a thread
  14. Private Declare Function GetThreadPriority Lib "kernel32" (ByVal hThread As Long) As Long
  15. 'Enables a disabled Thread
  16. Private Declare Function ResumeThread Lib "kernel32" (ByVal hThread As Long) As Long
  17. 'Disables a thread
  18. Private Declare Function SuspendThread Lib "kernel32" (ByVal hThread As Long) As Long
  19. 'Returns the handle of the current thread
  20. Private Declare Function GetCurrentThread Lib "kernel32" () As Long
  21. 'Returns the ID of the current thread
  22. Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
  23.  
  24. 'Consts
  25. Private Const MAXLONG = &H7FFFFFFF
  26.  
  27. 'Thread priority consts
  28. Private Const THREAD_BASE_PRIORITY_IDLE = -15
  29. Private Const THREAD_BASE_PRIORITY_LOWRT = 15
  30. Private Const THREAD_BASE_PRIORITY_MAX = 2
  31. Private Const THREAD_BASE_PRIORITY_MIN = -2
  32. Private Const THREAD_PRIORITY_HIGHEST = THREAD_BASE_PRIORITY_MAX
  33. Private Const THREAD_PRIORITY_LOWEST = THREAD_BASE_PRIORITY_MIN
  34. Private Const THREAD_PRIORITY_ABOVE_NORMAL = (THREAD_PRIORITY_HIGHEST - 1)
  35. Private Const THREAD_PRIORITY_BELOW_NORMAL = (THREAD_PRIORITY_LOWEST + 1)
  36. Private Const THREAD_PRIORITY_ERROR_RETURN = (MAXLONG)
  37. Private Const THREAD_PRIORITY_IDLE = THREAD_BASE_PRIORITY_IDLE
  38. Private Const THREAD_PRIORITY_NORMAL = 0
  39. Private Const THREAD_PRIORITY_TIME_CRITICAL = THREAD_BASE_PRIORITY_LOWRT
  40.  
  41. 'Thread creation flags
  42. Private Const CREATE_ALWAYS = 2
  43. Private Const CREATE_NEW = 1
  44. Private Const CREATE_NEW_CONSOLE = &H10
  45. Private Const CREATE_NEW_PROCESS_GROUP = &H200
  46. Private Const CREATE_NO_WINDOW = &H8000000
  47. Private Const CREATE_PROCESS_DEBUG_EVENT = 3
  48. Private Const CREATE_SUSPENDED = &H4
  49. Private Const CREATE_THREAD_DEBUG_EVENT = 2
  50.  
  51. 'Types and Enums
  52. Public Enum ThreadPriority
  53.    tpLowest = THREAD_PRIORITY_LOWEST
  54.    tpBelowNormal = THREAD_PRIORITY_BELOW_NORMAL
  55.    tpNormal = THREAD_PRIORITY_NORMAL
  56.    tpAboveNormal = THREAD_PRIORITY_ABOVE_NORMAL
  57.    tpHighest = THREAD_PRIORITY_HIGHEST
  58. End Enum
  59.  
  60. 'Vars
  61. Private mThreadHandle As Long
  62. Private mThreadID As Long
  63. Private mPriority As Long
  64. Private mEnabled As Boolean
  65. Private mCreated As Boolean
  66. Private mID As Long
  67. Public Function CreateNewThread(ByVal iDownloader As Long, ByVal cFunction As Long, Optional ByVal cPriority As Long = tpNormal, Optional ByVal cEnabled As Boolean = True)
  68.    'Creates a new Thread
  69.    Dim mHandle As Long
  70.    Dim CreationFlags As Long
  71.    Dim lpThreadID As Long
  72.  
  73.    'Look if the thread has already been created
  74.    If mCreated = True Then Exit Function
  75.  
  76.    'Look if the thread should be enabled
  77.    If cEnabled = True Then
  78.        CreationFlags = 0
  79.    Else
  80.        'Create a disabled thread, can be enabled later with the
  81.        ''Enabled' property
  82.        CreationFlags = CREATE_SUSPENDED
  83.    End If
  84.  
  85.    'The CreateThread Function returns the handle of the created thread;
  86.    'if the handle is 0, it failed creating the thread
  87.    mHandle = CreateThread(ByVal 0&, ByVal 0&, cFunction, ByVal 0&, CreationFlags, lpThreadID)
  88.  
  89.    If mHandle = 0 Then 'Failed creating the thread
  90.        'Insert your own error handling
  91.        'Debug.Print "InitializeThread Function in clsThreading failed creating a new thread"
  92.    Else
  93.        mThreadHandle = mHandle
  94.        mThreadID = lpThreadID
  95.        mCreated = True
  96.        mID = iDownloader
  97.    End If
  98. End Function
  99. Public Property Get iDownloader() As Long
  100.    iDownloader = mID
  101. End Property
  102. Public Function TerminateCurrentThread()
  103.    'Terminates the current thread
  104.  
  105.    'Ignore errors to prevent crashing if no thread has been created
  106.    On Error Resume Next
  107.    'Terminate the thread to prevent crashing if the app is closed
  108.    'and the thread is still running (dangerous!)
  109.    Call TerminateThread(mThreadHandle, ByVal 0&)
  110.    mCreated = False
  111. End Function
  112.  
  113. Public Property Get ThreadHandle() As Long
  114.    'Returns the Handle of the current Thread
  115.    ThreadHandle = mThreadHandle
  116. End Property
  117.  
  118. Public Property Get ThreadID() As Long
  119.    'Returns the ID of the current thread
  120.    ThreadID = mThreadID
  121. End Property
  122.  
  123. Public Property Get Priority() As Long
  124.    'Returns a long value because the thread might have other priorities
  125.    'than our five in the enum
  126.  
  127.    'Ignore errors to prevent crashing if no thread has been created
  128.    On Error Resume Next
  129.    Priority = GetThreadPriority(mThreadHandle)
  130. End Property
  131.  
  132. Public Property Let Priority(ByVal tmpValue As Long)
  133.    'Sets the Thread Priority of the actual thread
  134.    mPriority = tmpValue
  135.    Call SetThreadPriority(mThreadHandle, tmpValue)
  136. End Property
  137.  
  138. Public Property Get Enabled() As Boolean
  139.    'Returns whether the Thread is enabled or not
  140.    Enabled = mEnabled
  141. End Property
  142.  
  143. Public Property Let Enabled(ByVal tmpValue As Boolean)
  144.    'Enables/Disables the Thread
  145.  
  146.    'Ignore errors to prevent crashing if no thread has been created
  147.    On Error Resume Next
  148.    If tmpValue = True Then
  149.        'Enable the thread
  150.        Call ResumeThread(mThreadHandle)
  151.    ElseIf tmpValue = False Then
  152.        'Disable the thread
  153.        Call SuspendThread(mThreadHandle)
  154.    End If
  155. End Property
  156.  
  157. Private Sub Class_Terminate()
  158.    'Terminate the thread to prevent crashing if the app is closed
  159.    'and the thread is still running (dangerous!)
  160.    Call TerminateCurrentThread
  161. End Sub
  162.  

Código
  1. '----------------------------------------------------------------------------------------'
  2. '
  3. ' Multi Downloader using multithreadings
  4. ' Created by Suk Yong Kim, 03/14/2001
  5. '
  6. ' This project is my first project to upload to the PSC.
  7. ' Many persons contribute to create this project
  8. ' I really appreicate their efforts and codes and the great server PSC.
  9. '
  10. ' if any question, mail to : techtrans@dreamwiz.com
  11. '----------------------------------------------------------------------------------------'
  12.  
  13. Option Explicit
  14.  
  15. 'local variable to hold collection
  16. Private mCol As Collection
  17.  
  18.  
  19. Public Function CreateNewThread(ByVal iDownloader As Long, ByVal cFunction As Long, _
  20.    Optional ByVal cPriority As Long = tpNormal, _
  21.    Optional ByVal cEnabled As Boolean = True, Optional sKey As String) As clsThreading
  22.  
  23.    'create a new object
  24.    Dim objNewMember As clsThreading
  25.    Set objNewMember = New clsThreading
  26.  
  27.    'create new thread
  28.    Call objNewMember.CreateNewThread(iDownloader, cFunction, cPriority, cEnabled)
  29.  
  30.    If Len(sKey) = 0 Then
  31.      mCol.Add objNewMember
  32.    Else
  33.      mCol.Add objNewMember, sKey
  34.    End If
  35.  
  36.    'return the object created
  37.    Set CreateNewThread = objNewMember
  38.    Set objNewMember = Nothing
  39. Exit_Function:
  40. End Function
  41. Public Property Get Item(vntIndexKey As Variant) As clsThreading
  42.    Set Item = mCol(vntIndexKey)
  43. End Property
  44.  
  45. Public Property Get Count() As Long
  46.    Count = mCol.Count
  47. End Property
  48.  
  49. Public Sub TerminateThread(vntIndexKey As Variant)
  50.    On Error Resume Next
  51.    mCol.Remove vntIndexKey
  52. End Sub
  53.  
  54. Public Property Get NewEnum() As IUnknown
  55.    Set NewEnum = mCol.[_NewEnum]
  56. End Property
  57.  
  58. Private Sub Class_Initialize()
  59.    Set mCol = New Collection
  60. End Sub
  61.  
  62. Private Sub Class_Terminate()
  63.    On Error Resume Next
  64.    Set mCol = Nothing
  65. End Sub
  66.  
En línea



<[(x)]>

Desconectado Desconectado

Mensajes: 215



Ver Perfil
Re: problema para mostrar 'cargando...'
« Respuesta #7 en: 21 Junio 2009, 05:38 am »



Bien ya esta andando.

 Gracias a todos  ;-)

 s2 <[(x)]>
En línea

<[(x)]>
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
(SOLUCIONADO) Problema para mostrar el menú de la terminal
GNU/Linux
Fischer987 5 4,609 Último mensaje 15 Febrero 2011, 01:25 am
por Fischer987
Cargando imagenes con ajax... problema
Desarrollo Web
WD 4 4,612 Último mensaje 2 Julio 2011, 05:50 am
por WD
Problema GRUB2 cargando kernel
Programación C/C++
armizh 3 2,039 Último mensaje 25 Febrero 2012, 23:31 pm
por Eternal Idol
Problema con mostrar listado
Programación C/C++
Rhythmical 1 2,057 Último mensaje 16 Noviembre 2017, 22:21 pm
por MAFUS
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines